tests(iam-admin): add 90s warmup delay to prevent service account creation race condition#13016
tests(iam-admin): add 90s warmup delay to prevent service account creation race condition#13016
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a 90-second delay using a time_sleep resource after enabling the IAM API to ensure it is fully operational before the service account is created. Feedback suggests adding a conditional count to the time_sleep resource so the delay only occurs when the API is actually being enabled by the Terraform configuration, preventing unnecessary wait times when the API is already active.
| resource "time_sleep" "for_90s_allowIamToFullyEnable" { | ||
| depends_on = [google_project_service.iam] | ||
| create_duration = "90s" | ||
| } |
There was a problem hiding this comment.
The time_sleep resource should only be active when the IAM API is being enabled by this Terraform configuration. As currently implemented, it will introduce a 90-second delay during the initial terraform apply even if should_enable_apis_on_apply is set to false. Adding a count to match the google_project_service.iam resource ensures the delay only occurs when the API is actually being managed and enabled here.
resource "time_sleep" "for_90s_allowIamToFullyEnable" {
count = var.inputs.should_enable_apis_on_apply ? 1 : 0
depends_on = [google_project_service.iam]
create_duration = "90s"
}
9d1b9de to
96390cc
Compare
96390cc to
424d2d8
Compare
This PR addresses a transient propagation race condition in the
java-iam-adminmodule's Terraform setup.See the error log for details.
Previously, the
google_service_account.service_accountresource directly depended on thegoogle_project_service.iamAPI activation without any warmup sleep. Since the IAM API activation requires global directory replication and backend propagation inside GCP, immediately attempting to create a service account after API activation frequently caused a transient"Provider produced inconsistent result"failure duringterraform apply.This fix adds a 90-second warmup delay (
time_sleep) right after enabling theiam.googleapis.comservice and before creating the service account. This matches the established best practices already utilized by other modules in this monorepo (likejava-tasks,java-texttospeech,java-notification, andjava-asset).Verification