From a06d7d70f30f577ac167b1c5584b931d5447025b Mon Sep 17 00:00:00 2001 From: Ankita Thomas Date: Tue, 22 Aug 2023 10:23:28 -0400 Subject: [PATCH] retry unpacking jobs on failure Signed-off-by: Ankita Thomas --- pkg/controller/bundle/bundle_unpacker.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/controller/bundle/bundle_unpacker.go b/pkg/controller/bundle/bundle_unpacker.go index 79f67ab177..f9fa1fcea6 100644 --- a/pkg/controller/bundle/bundle_unpacker.go +++ b/pkg/controller/bundle/bundle_unpacker.go @@ -659,6 +659,14 @@ func (c *ConfigMapUnpacker) ensureJob(cmRef *corev1.ObjectReference, bundlePath return } + // Cleanup old unpacking job and retry + if _, isFailed := getCondition(job, batchv1.JobFailed); isFailed { + err = c.client.BatchV1().Jobs(job.GetNamespace()).Delete(context.TODO(), job.GetName(), metav1.DeleteOptions{}) + if err == nil { + job, err = c.client.BatchV1().Jobs(fresh.GetNamespace()).Create(context.TODO(), fresh, metav1.CreateOptions{}) + } + return + } if equality.Semantic.DeepDerivative(fresh.GetOwnerReferences(), job.GetOwnerReferences()) && equality.Semantic.DeepDerivative(fresh.Spec, job.Spec) { return