Skip to content

Commit 8c4e751

Browse files
committed
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 <[email protected]> Upstream-repository: operator-lifecycle-manager Upstream-commit: 8751ca0212e345a0b7eab452b169d926e7f42437
1 parent 2069e35 commit 8c4e751

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

staging/operator-lifecycle-manager/pkg/controller/bundle/bundle_unpacker_test.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,14 +1206,15 @@ func TestConfigMapUnpacker(t *testing.T) {
12061206
},
12071207
},
12081208
{
1209-
description: "CatalogSourcePresent/JobFailed/BundleLookupFailed/WithJobFailReason",
1209+
description: "CatalogSourcePresent/JobFailed/BundleLookupFailed/WithJobFailReasonNoLabel",
12101210
fields: fields{
12111211
objs: []runtime.Object{
12121212
&batchv1.Job{
12131213
ObjectMeta: metav1.ObjectMeta{
12141214
Name: pathHash,
12151215
Namespace: "ns-a",
1216-
Labels: map[string]string{install.OLMManagedLabelKey: install.OLMManagedLabelValue, bundleUnpackRefLabel: pathHash},
1216+
//omit the "operatorframework.io/bundle-unpack-ref" label
1217+
Labels: map[string]string{install.OLMManagedLabelKey: install.OLMManagedLabelValue},
12171218
OwnerReferences: []metav1.OwnerReference{
12181219
{
12191220
APIVersion: "v1",
@@ -1427,6 +1428,9 @@ func TestConfigMapUnpacker(t *testing.T) {
14271428
},
14281429
},
14291430
expected: expected{
1431+
// If job is not found due to missing "operatorframework.io/bundle-unpack-ref" label,
1432+
// we will get an 'AlreadyExists' error in this test when the new job is created
1433+
err: nil,
14301434
res: &BundleUnpackResult{
14311435
name: pathHash,
14321436
BundleLookup: &operatorsv1alpha1.BundleLookup{
@@ -1459,7 +1463,7 @@ func TestConfigMapUnpacker(t *testing.T) {
14591463
ObjectMeta: metav1.ObjectMeta{
14601464
Name: pathHash,
14611465
Namespace: "ns-a",
1462-
Labels: map[string]string{install.OLMManagedLabelKey: install.OLMManagedLabelValue, bundleUnpackRefLabel: pathHash},
1466+
Labels: map[string]string{install.OLMManagedLabelKey: install.OLMManagedLabelValue},
14631467
OwnerReferences: []metav1.OwnerReference{
14641468
{
14651469
APIVersion: "v1",

0 commit comments

Comments
 (0)