diff --git a/google/resource_google_project_services.go b/google/resource_google_project_services.go index 4d8120b172c..f8afba6d535 100644 --- a/google/resource_google_project_services.go +++ b/google/resource_google_project_services.go @@ -186,7 +186,7 @@ func getApiServices(pid string, config *Config, ignore map[string]struct{}) ([]s func enableService(s, pid string, config *Config) error { esr := newEnableServiceRequest(pid) - err := retry(func() error { + err := retryTime(func() error { sop, err := config.clientServiceMan.Services.Enable(s, esr).Do() if err != nil { return err @@ -196,7 +196,7 @@ func enableService(s, pid string, config *Config) error { return waitErr } return nil - }) + }, 10) if err != nil { return fmt.Errorf("Error enabling service %q for project %q: %v", s, pid, err) } @@ -205,7 +205,7 @@ func enableService(s, pid string, config *Config) error { func disableService(s, pid string, config *Config) error { dsr := newDisableServiceRequest(pid) - err := retry(func() error { + err := retryTime(func() error { sop, err := config.clientServiceMan.Services.Disable(s, dsr).Do() if err != nil { return err @@ -216,7 +216,7 @@ func disableService(s, pid string, config *Config) error { return waitErr } return nil - }) + }, 10) if err != nil { return fmt.Errorf("Error disabling service %q for project %q: %v", s, pid, err) } diff --git a/google/utils.go b/google/utils.go index 66f89150c81..f2055acef49 100644 --- a/google/utils.go +++ b/google/utils.go @@ -385,7 +385,11 @@ func mergeSchemas(a, b map[string]*schema.Schema) map[string]*schema.Schema { } func retry(retryFunc func() error) error { - return resource.Retry(1*time.Minute, func() *resource.RetryError { + return retryTime(retryFunc, 1) +} + +func retryTime(retryFunc func() error, minutes int) error { + return resource.Retry(time.Duration(minutes)*time.Minute, func() *resource.RetryError { err := retryFunc() if err == nil { return nil