Skip to content

Commit

Permalink
Fix the SQL instance sweeper so that it is more resilient to failures (
Browse files Browse the repository at this point in the history
…#8710) (#6126)

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Aug 21, 2023
1 parent cb1f634 commit 379da6c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .changelog/8710.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:none

```
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,11 @@ func testSweepSQLDatabaseInstance(region string) error {
// need to stop replication before being able to destroy a database
op, err := config.NewSqlAdminClient(config.UserAgent).Instances.StopReplica(config.Project, replicaName).Do()

// if the replica can't be stopped, still try deleting it later (in case it is stopped by then)
if err != nil {
log.Printf("error, failed to stop replica instance (%s) for instance (%s): %s", replicaName, d.Name, err)
return nil
ordering = append(ordering, replicaName)
continue
}

err = SqlAdminOperationWaitTime(config, op, config.Project, "Stop Replica", config.UserAgent, 10*time.Minute)
Expand All @@ -88,7 +90,6 @@ func testSweepSQLDatabaseInstance(region string) error {
log.Printf("Replication operation not found")
} else {
log.Printf("Error waiting for sqlAdmin operation: %s", err)
return nil
}
}

Expand All @@ -111,7 +112,7 @@ func testSweepSQLDatabaseInstance(region string) error {
}

log.Printf("Error, failed to delete instance %s: %s", db, err)
return nil
continue
}

err = SqlAdminOperationWaitTime(config, op, config.Project, "Delete Instance", config.UserAgent, 10*time.Minute)
Expand All @@ -121,7 +122,6 @@ func testSweepSQLDatabaseInstance(region string) error {
continue
}
log.Printf("Error, failed to delete instance %s: %s", db, err)
return nil
}
}
}
Expand Down

0 comments on commit 379da6c

Please sign in to comment.