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

Retry delete network step while creating a google project. #17419

Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions .changelog/10046.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resourcemanager: added a retry to deleting the default network when `auto_create_network` is false in `google_project`
```
8 changes: 7 additions & 1 deletion google/services/resourcemanager/resource_google_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,13 @@ func resourceGoogleProjectCreate(d *schema.ResourceData, meta interface{}) error
return errwrap.Wrapf("Error enabling the Compute Engine API required to delete the default network: {{err}} ", err)
}

if err = forceDeleteComputeNetwork(d, config, project.ProjectId, "default"); err != nil {
err = forceDeleteComputeNetwork(d, config, project.ProjectId, "default")
// Retry if API is not yet enabled.
if err != nil && transport_tpg.IsGoogleApiErrorWithCode(err, 403) {
time.Sleep(10 * time.Second)
err = forceDeleteComputeNetwork(d, config, project.ProjectId, "default")
}
if err != nil {
if transport_tpg.IsGoogleApiErrorWithCode(err, 404) {
log.Printf("[DEBUG] Default network not found for project %q, no need to delete it", project.ProjectId)
} else {
Expand Down
Loading