Skip to content

Commit

Permalink
Change migrate retry logic to always retry on error
Browse files Browse the repository at this point in the history
* Before the migration code expected in that certain errors would
  return both a connection and an error, which is very much not
  idomatic go and was confusing. Now we always retry, regardless of
  error.
  • Loading branch information
Andrew Hobson committed Nov 7, 2022
1 parent 4746dec commit 73d13c0
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions cmd/milmove/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,15 +233,8 @@ func migrateFunction(cmd *cobra.Command, args []string) error {
for retryCount < retryMax {
dbConnection, errDbConn = cli.InitDatabase(v, dbCreds, logger)
if errDbConn != nil {
if dbConnection == nil {
// No connection object means that the configuraton failed to validate and we should kill server startup
logger.Fatal("Invalid DB Configuration", zap.Error(errDbConn))
} else {
// A valid connection object that still has an error indicates that the DB is not up and
// thus is not ready for migrations. Attempt to retry connecting.
logger.Error(fmt.Sprintf("DB is not ready for connections, sleeping for %q", retryInterval), zap.Error(errDbConn))
time.Sleep(retryInterval)
}
logger.Error(fmt.Sprintf("DB is not ready for connections, sleeping for %q", retryInterval), zap.Error(errDbConn))
time.Sleep(retryInterval)
} else {
break
}
Expand Down

0 comments on commit 73d13c0

Please sign in to comment.