Skip to content

Commit 28befe2

Browse files
Merge pull request #810 from dtfranz/job-create-4-15
[release-4.15] OCPBUGS-36451: Can't install operator on 4.15 after uninstalling it on a prior version
2 parents 882fdf4 + 8c4e751 commit 28befe2

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
@@ -666,6 +666,19 @@ func (c *ConfigMapUnpacker) ensureJob(cmRef *corev1.ObjectReference, bundlePath
666666
if err != nil {
667667
return
668668
}
669+
670+
// This is to ensure that we account for any existing unpack jobs that may be missing the label
671+
jobWithoutLabel, err := c.jobLister.Jobs(fresh.GetNamespace()).Get(cmRef.Name)
672+
if err != nil && !apierrors.IsNotFound(err) {
673+
return
674+
}
675+
if jobWithoutLabel != nil {
676+
_, labelExists := jobWithoutLabel.Labels[bundleUnpackRefLabel]
677+
if !labelExists {
678+
jobs = append(jobs, jobWithoutLabel)
679+
}
680+
}
681+
669682
if len(jobs) == 0 {
670683
job, err = c.client.BatchV1().Jobs(fresh.GetNamespace()).Create(context.TODO(), fresh, metav1.CreateOptions{})
671684
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
@@ -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",

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)