Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,19 @@ func (c *ConfigMapUnpacker) ensureJob(cmRef *corev1.ObjectReference, bundlePath
if err != nil {
return
}

// This is to ensure that we account for any existing unpack jobs that may be missing the label
jobWithoutLabel, err := c.jobLister.Jobs(fresh.GetNamespace()).Get(cmRef.Name)
if err != nil && !apierrors.IsNotFound(err) {
return
}
if jobWithoutLabel != nil {
_, labelExists := jobWithoutLabel.Labels[bundleUnpackRefLabel]
if !labelExists {
jobs = append(jobs, jobWithoutLabel)
}
}

if len(jobs) == 0 {
job, err = c.client.BatchV1().Jobs(fresh.GetNamespace()).Create(context.TODO(), fresh, metav1.CreateOptions{})
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.