fix(ci): add sleep between service enablement and resource creation#5444
fix(ci): add sleep between service enablement and resource creation#5444haphungw wants to merge 1 commit intogoogleapis:mainfrom
Conversation
dbolduc
left a comment
There was a problem hiding this comment.
If I already have the service enabled, does it still sleep for 60 seconds?
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5444 +/- ##
==========================================
- Coverage 97.74% 97.74% -0.01%
==========================================
Files 216 216
Lines 47549 47549
==========================================
- Hits 46478 46477 -1
- Misses 1071 1072 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Two trade-offs regarding this delay:
Yes if |
dbolduc
left a comment
There was a problem hiding this comment.
Yes if
time_sleepis not recorded in the state file (local or remote).
I am fine with this. It only gets added once.
| # Service enablement can take time to propagate. | ||
| resource "time_sleep" "wait_for_services" { | ||
| create_duration = "60s" | ||
| depends_on = [module.services] |
There was a problem hiding this comment.
Apparently we want to use triggers to have this sleep take affect when the services change. depends_on alone doesn't do that, it just controls the order of operations.
https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep#triggers-usage
To prevent flakes of
services not enabledimmediately after activation, I'm proposing to add atime_sleepdelay of 60 seconds.As noted in the Official Google Provider Guide, GCP APIs often return success at the global control plane before propagation to regional infrastructure is complete. This delay ensures resources like Firestore and KMS create successfully on the first run.
For reference, this pattern is also used in the official Google Cloud Datastore Module example, where they use a 120-second delay to make sure App Engine applications are initialized before creating indexes.