From e2c10e6d06ed118eada90f971f97fc9ab82c3e4a Mon Sep 17 00:00:00 2001 From: Kenny Lee Sin Cheong Date: Thu, 3 Oct 2019 11:23:58 -0400 Subject: [PATCH] Log the job status to the ManagedDatabase --- controllers/manageddatabase_controller.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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