Skip to content

Commit

Permalink
Retry delete network step while creating a google project. (#10046)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajaybgunjal1 authored Feb 26, 2024
1 parent b449d45 commit 7faaacc
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,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

0 comments on commit 7faaacc

Please sign in to comment.