Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add another retry if iam read returns nil #2629

Merged
merged 1 commit into from
Dec 11, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions google/iam.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ func iamPolicyReadModifyWrite(updater ResourceIamUpdater, modify iamPolicyModify
if err == nil {
fetchBackoff := 1 * time.Second
for successfulFetches := 0; successfulFetches < 3; {
if fetchBackoff > 30*time.Second {
return fmt.Errorf("Error applying IAM policy to %s: Waited too long for propagation.\n", updater.DescribeResource())
}
time.Sleep(fetchBackoff)
log.Printf("[DEBUG]: Retrieving policy for %s\n", updater.DescribeResource())
new_p, err := updater.GetResourceIamPolicy()
if err != nil {
// Quota for Read is pretty limited, so watch out for running out of quota.
Expand All @@ -81,6 +85,12 @@ func iamPolicyReadModifyWrite(updater ResourceIamUpdater, modify iamPolicyModify
return err
}
}
log.Printf("[DEBUG]: Retrieved policy for %s: %+v\n", updater.DescribeResource(), p)
if new_p == nil {
// https://github.com/terraform-providers/terraform-provider-google/issues/2625
fetchBackoff = fetchBackoff * 2
continue
}
modified_p := new_p
// This relies on the fact that `modify` is idempotent: since other changes might have
// happened between the call to set the policy and now, we just need to make sure that
Expand All @@ -94,9 +104,6 @@ func iamPolicyReadModifyWrite(updater ResourceIamUpdater, modify iamPolicyModify
successfulFetches += 1
} else {
fetchBackoff = fetchBackoff * 2
if fetchBackoff > 30*time.Second {
return fmt.Errorf("Error applying IAM policy to %s: Waited too long for propagation.\n", updater.DescribeResource())
}
}
}
break
Expand Down