From 8751ca0212e345a0b7eab452b169d926e7f42437 Mon Sep 17 00:00:00 2001 From: Daniel Franz Date: Fri, 31 May 2024 02:30:58 -0700 Subject: [PATCH] Unpack Job Creation Failure Test (#3297) Extends an existing unit test to cover the scenario where an old, failed job missing the label added in later OLM versions is not found with the filtered list call, resulting in an 'AlreadyExists' error when the new job is created. Signed-off-by: Daniel Franz --- pkg/controller/bundle/bundle_unpacker_test.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/controller/bundle/bundle_unpacker_test.go b/pkg/controller/bundle/bundle_unpacker_test.go index cca9371c3a..4e3468b210 100644 --- a/pkg/controller/bundle/bundle_unpacker_test.go +++ b/pkg/controller/bundle/bundle_unpacker_test.go @@ -1218,14 +1218,15 @@ func TestConfigMapUnpacker(t *testing.T) { }, }, { - description: "CatalogSourcePresent/JobFailed/BundleLookupFailed/WithJobFailReason", + description: "CatalogSourcePresent/JobFailed/BundleLookupFailed/WithJobFailReasonNoLabel", fields: fields{ objs: []runtime.Object{ &batchv1.Job{ ObjectMeta: metav1.ObjectMeta{ Name: pathHash, Namespace: "ns-a", - Labels: map[string]string{install.OLMManagedLabelKey: install.OLMManagedLabelValue, bundleUnpackRefLabel: pathHash}, + //omit the "operatorframework.io/bundle-unpack-ref" label + Labels: map[string]string{install.OLMManagedLabelKey: install.OLMManagedLabelValue}, OwnerReferences: []metav1.OwnerReference{ { APIVersion: "v1", @@ -1442,6 +1443,9 @@ func TestConfigMapUnpacker(t *testing.T) { }, }, expected: expected{ + // If job is not found due to missing "operatorframework.io/bundle-unpack-ref" label, + // we will get an 'AlreadyExists' error in this test when the new job is created + err: nil, res: &BundleUnpackResult{ name: pathHash, BundleLookup: &operatorsv1alpha1.BundleLookup{ @@ -1474,7 +1478,7 @@ func TestConfigMapUnpacker(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ Name: pathHash, Namespace: "ns-a", - Labels: map[string]string{install.OLMManagedLabelKey: install.OLMManagedLabelValue, bundleUnpackRefLabel: pathHash}, + Labels: map[string]string{install.OLMManagedLabelKey: install.OLMManagedLabelValue}, OwnerReferences: []metav1.OwnerReference{ { APIVersion: "v1",