@@ -71,7 +71,11 @@ func iamPolicyReadModifyWrite(updater ResourceIamUpdater, modify iamPolicyModify
71
71
if err == nil {
72
72
fetchBackoff := 1 * time .Second
73
73
for successfulFetches := 0 ; successfulFetches < 3 ; {
74
+ if fetchBackoff > 30 * time .Second {
75
+ return fmt .Errorf ("Error applying IAM policy to %s: Waited too long for propagation.\n " , updater .DescribeResource ())
76
+ }
74
77
time .Sleep (fetchBackoff )
78
+ log .Printf ("[DEBUG]: Retrieving policy for %s\n " , updater .DescribeResource ())
75
79
new_p , err := updater .GetResourceIamPolicy ()
76
80
if err != nil {
77
81
// Quota for Read is pretty limited, so watch out for running out of quota.
@@ -81,6 +85,12 @@ func iamPolicyReadModifyWrite(updater ResourceIamUpdater, modify iamPolicyModify
81
85
return err
82
86
}
83
87
}
88
+ log .Printf ("[DEBUG]: Retrieved policy for %s: %+v\n " , updater .DescribeResource (), p )
89
+ if new_p == nil {
90
+ // https://github.com/terraform-providers/terraform-provider-google/issues/2625
91
+ fetchBackoff = fetchBackoff * 2
92
+ continue
93
+ }
84
94
modified_p := new_p
85
95
// This relies on the fact that `modify` is idempotent: since other changes might have
86
96
// happened between the call to set the policy and now, we just need to make sure that
@@ -94,9 +104,6 @@ func iamPolicyReadModifyWrite(updater ResourceIamUpdater, modify iamPolicyModify
94
104
successfulFetches += 1
95
105
} else {
96
106
fetchBackoff = fetchBackoff * 2
97
- if fetchBackoff > 30 * time .Second {
98
- return fmt .Errorf ("Error applying IAM policy to %s: Waited too long for propagation.\n " , updater .DescribeResource ())
99
- }
100
107
}
101
108
}
102
109
break
0 commit comments