Skip to content
This repository has been archived by the owner on Mar 11, 2022. It is now read-only.

Commit

Permalink
gitopsconfig: make sure bad img blocked job
Browse files Browse the repository at this point in the history
Double-check if the existing job is blocked because of bad image. Add
checking if there is only one active pod of a job, which occurs when
nonexistent or wrong image blocks the job. Thanks to it only such case
will fall under the if code block.
Before, if there was a "normal" fail of a job (i.e. code inside
container exited 1), and there were a few failed pods, this would fall
under the if block, and jobContainerStatus function would return an
error because the job had a few pods.
  • Loading branch information
sbar95 committed Feb 24, 2020
1 parent 6cd133f commit 213d80e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/controller/gitopsconfig/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,8 @@ func (r *Reconciler) manageDeletion(instance *gitopsv1alpha1.GitOpsConfig) (reco
// assume the GitOpsConfig never managed to successfully deploy, so we can
// just delete the job, remove the finalizer, and be done (#216). It may be
// either action=create or action=delete job.
if len(jobs) == 1 {
// If a job is blocked because of bad image, it only has one active pod
if len(jobs) == 1 && jobs[0].Status.Succeeded == 0 && jobs[0].Status.Failed == 0 && jobs[0].Status.Active == 1 {
status, err := jobContainerStatus(context.TODO(), r.client, &jobs[0])
if err != nil {
log.Error(err, "GitOpsConfig finalizer unable to get job pod's status", "instance", instance.Name)
Expand Down

0 comments on commit 213d80e

Please sign in to comment.