From 47aaa6be4a951c6bd8be016f6610c5319adc6a47 Mon Sep 17 00:00:00 2001 From: Kevin Rizza Date: Wed, 17 Apr 2024 15:02:50 -0400 Subject: [PATCH] Fix unpack job cache issue (#3204) In the same vein as https://github.com/operator-framework/operator-lifecycle-manager/pull/3202, use update if the unpack job already exists but isn't cached Signed-off-by: kevinrizza --- pkg/controller/bundle/bundle_unpacker.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/controller/bundle/bundle_unpacker.go b/pkg/controller/bundle/bundle_unpacker.go index 3fee77fa1b..489d07dada 100644 --- a/pkg/controller/bundle/bundle_unpacker.go +++ b/pkg/controller/bundle/bundle_unpacker.go @@ -671,6 +671,9 @@ func (c *ConfigMapUnpacker) ensureJob(cmRef *corev1.ObjectReference, bundlePath } if len(jobs) == 0 { job, err = c.client.BatchV1().Jobs(fresh.GetNamespace()).Create(context.TODO(), fresh, metav1.CreateOptions{}) + if apierrors.IsAlreadyExists(err) { + job, err = c.client.BatchV1().Jobs(fresh.GetNamespace()).Update(context.TODO(), fresh, metav1.UpdateOptions{}) + } return } @@ -685,6 +688,9 @@ func (c *ConfigMapUnpacker) ensureJob(cmRef *corev1.ObjectReference, bundlePath if time.Now().After(cond.LastTransitionTime.Time.Add(unpackRetryInterval)) { fresh.SetName(names.SimpleNameGenerator.GenerateName(fresh.GetName())) job, err = c.client.BatchV1().Jobs(fresh.GetNamespace()).Create(context.TODO(), fresh, metav1.CreateOptions{}) + if apierrors.IsAlreadyExists(err) { + job, err = c.client.BatchV1().Jobs(fresh.GetNamespace()).Update(context.TODO(), fresh, metav1.UpdateOptions{}) + } } }