mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-07-09 03:28:29 +00:00
Retry while listing enabled services (#1573)
This fixes GH-1562 for realz
This commit is contained in:
parent
5f0dcf4787
commit
aff6bc6519
|
@ -187,14 +187,19 @@ func getConfigServices(d *schema.ResourceData) (services []string) {
|
||||||
|
|
||||||
// Retrieve a project's services from the API
|
// Retrieve a project's services from the API
|
||||||
func getApiServices(pid string, config *Config, ignore map[string]struct{}) ([]string, error) {
|
func getApiServices(pid string, config *Config, ignore map[string]struct{}) ([]string, error) {
|
||||||
var apiServices []string
|
|
||||||
|
|
||||||
if ignore == nil {
|
if ignore == nil {
|
||||||
ignore = make(map[string]struct{})
|
ignore = make(map[string]struct{})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var apiServices []string
|
||||||
|
|
||||||
|
if err := retryTime(func() error {
|
||||||
|
// Reset the list of apiServices in case of a retry. A partial page failure
|
||||||
|
// could result in duplicate services.
|
||||||
|
apiServices = make([]string, 0, 10)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
if err := config.clientServiceUsage.Services.
|
return config.clientServiceUsage.Services.
|
||||||
List("projects/"+pid).
|
List("projects/"+pid).
|
||||||
Fields("services/name").
|
Fields("services/name").
|
||||||
Filter("state:ENABLED").
|
Filter("state:ENABLED").
|
||||||
|
@ -211,7 +216,8 @@ func getApiServices(pid string, config *Config, ignore map[string]struct{}) ([]s
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}); err != nil {
|
})
|
||||||
|
}, 10); err != nil {
|
||||||
return nil, errwrap.Wrapf("failed to list services: {{err}}", err)
|
return nil, errwrap.Wrapf("failed to list services: {{err}}", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user