diff --git a/controllers/manageddatabase_controller.go b/controllers/manageddatabase_controller.go index 22fb945..a5dad30 100644 --- a/controllers/manageddatabase_controller.go +++ b/controllers/manageddatabase_controller.go @@ -177,13 +177,19 @@ func (c *ManagedDatabaseController) reconcileMigrationJob(oneMigration migration for _, job := range jobsForDatabase.Items { if job.Labels["migration-uid"] == string(oneMigration.version.UID) { // This is the job for the migration in question - oneMigration.log.Info("Found matching migration") + oneMigration.log.Info("Found matching migration job") foundJob = true if job.Status.Succeeded > 0 { - oneMigration.log.Info("Migration is complete") + oneMigration.log.Info("Migration job is complete") // TODO: should we write the metric here or wait until cleanup? + } else if job.Status.Active == 0 && job.Status.Conditions != nil { + for _, condition := range job.Status.Conditions { + if condition.Type == "Failed" && condition.Status == "True" { + return fmt.Errorf("Migration job failed to complete (%s)", job.Name) + } + } } } else { // This is an old job and should be cleaned up