Skip to content

Commit f4eac42

Browse files
Merge pull request #809 from dtfranz/job-create-4-16
[release-4.16] OCPBUGS-36450: Can't install operator on 4.15 after uninstalling it on a prior version
2 parents ee44d6c + ea03cd9 commit f4eac42

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,19 @@ func (c *ConfigMapUnpacker) ensureJob(cmRef *corev1.ObjectReference, bundlePath
669669
if err != nil {
670670
return
671671
}
672+
673+
// This is to ensure that we account for any existing unpack jobs that may be missing the label
674+
jobWithoutLabel, err := c.jobLister.Jobs(fresh.GetNamespace()).Get(cmRef.Name)
675+
if err != nil && !apierrors.IsNotFound(err) {
676+
return
677+
}
678+
if jobWithoutLabel != nil {
679+
_, labelExists := jobWithoutLabel.Labels[bundleUnpackRefLabel]
680+
if !labelExists {
681+
jobs = append(jobs, jobWithoutLabel)
682+
}
683+
}
684+
672685
if len(jobs) == 0 {
673686
job, err = c.client.BatchV1().Jobs(fresh.GetNamespace()).Create(context.TODO(), fresh, metav1.CreateOptions{})
674687
return

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
@@ -1218,14 +1218,15 @@ func TestConfigMapUnpacker(t *testing.T) {
12181218
},
12191219
},
12201220
{
1221-
description: "CatalogSourcePresent/JobFailed/BundleLookupFailed/WithJobFailReason",
1221+
description: "CatalogSourcePresent/JobFailed/BundleLookupFailed/WithJobFailReasonNoLabel",
12221222
fields: fields{
12231223
objs: []runtime.Object{
12241224
&batchv1.Job{
12251225
ObjectMeta: metav1.ObjectMeta{
12261226
Name: pathHash,
12271227
Namespace: "ns-a",
1228-
Labels: map[string]string{install.OLMManagedLabelKey: install.OLMManagedLabelValue, bundleUnpackRefLabel: pathHash},
1228+
//omit the "operatorframework.io/bundle-unpack-ref" label
1229+
Labels: map[string]string{install.OLMManagedLabelKey: install.OLMManagedLabelValue},
12291230
OwnerReferences: []metav1.OwnerReference{
12301231
{
12311232
APIVersion: "v1",
@@ -1442,6 +1443,9 @@ func TestConfigMapUnpacker(t *testing.T) {
14421443
},
14431444
},
14441445
expected: expected{
1446+
// If job is not found due to missing "operatorframework.io/bundle-unpack-ref" label,
1447+
// we will get an 'AlreadyExists' error in this test when the new job is created
1448+
err: nil,
14451449
res: &BundleUnpackResult{
14461450
name: pathHash,
14471451
BundleLookup: &operatorsv1alpha1.BundleLookup{
@@ -1474,7 +1478,7 @@ func TestConfigMapUnpacker(t *testing.T) {
14741478
ObjectMeta: metav1.ObjectMeta{
14751479
Name: pathHash,
14761480
Namespace: "ns-a",
1477-
Labels: map[string]string{install.OLMManagedLabelKey: install.OLMManagedLabelValue, bundleUnpackRefLabel: pathHash},
1481+
Labels: map[string]string{install.OLMManagedLabelKey: install.OLMManagedLabelValue},
14781482
OwnerReferences: []metav1.OwnerReference{
14791483
{
14801484
APIVersion: "v1",

vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/controller/bundle/bundle_unpacker.go

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)