Skip to content

Commit 300a337

Browse files
Merge pull request #596 from tmshort/OCPBUGS-17408
OCPBUGS-17408: Do not derive installplan.spec.clusterServiceNames from bundle IDs
2 parents ecb5392 + d77bc07 commit 300a337

File tree

3 files changed

+66
-6
lines changed
  • staging/operator-lifecycle-manager/pkg/controller/operators/catalog
  • vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/controller/operators/catalog

3 files changed

+66
-6
lines changed

staging/operator-lifecycle-manager/pkg/controller/operators/catalog/operator.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,9 +1536,7 @@ func (o *Operator) createInstallPlan(namespace string, gen int, subs []*v1alpha1
15361536
}
15371537
catalogSourceMap[s.Resource.CatalogSource] = struct{}{}
15381538
}
1539-
for _, b := range bundleLookups {
1540-
csvNames = append(csvNames, b.Identifier)
1541-
}
1539+
15421540
catalogSources := []string{}
15431541
for s := range catalogSourceMap {
15441542
catalogSources = append(catalogSources, s)

staging/operator-lifecycle-manager/pkg/controller/operators/catalog/operator_test.go

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,70 @@ func (m *mockTransitioner) ExecutePlan(plan *v1alpha1.InstallPlan) error {
7777
return m.err
7878
}
7979

80+
func TestCreateInstallPlanHasExpectedClusterServiceVersionNames(t *testing.T) {
81+
namespace := "foo"
82+
tests := []struct {
83+
testName string
84+
steps []*v1alpha1.Step
85+
bundleLookups []v1alpha1.BundleLookup
86+
expectedClusterServiceVersionNames []string
87+
}{
88+
/******************************************************************************
89+
Historically, when creating an installPlan it's spec.ClusterServiceVersionNames
90+
was derived from two sources:
91+
1. The names of CSVs found in "steps" of the installPlan's status.plan
92+
2. The metadata associated with the bundle image
93+
94+
These sources couldn't result in duplicate entries as the unpacking job would
95+
finish after the installPlan was created and the steps weren't populated until
96+
the unpacking job finished.
97+
98+
OLM was later updated to complete the unpacking jobs prior to creating
99+
the installPlan, which caused CSVs to be listed twice as the createInstallPlan
100+
function was called with steps and a bundle.
101+
*****************************************************************************/
102+
{
103+
testName: "Check that CSVs are not listed twice if steps and bundles are provided",
104+
steps: []*v1alpha1.Step{{
105+
Resolving: "csv",
106+
Resource: v1alpha1.StepResource{
107+
CatalogSource: "catalog",
108+
CatalogSourceNamespace: namespace,
109+
Group: "operators.coreos.com",
110+
Version: "v1alpha1",
111+
Kind: "ClusterServiceVersion",
112+
Name: "csvA",
113+
Manifest: toManifest(t, csv("csvA", namespace, nil, nil)),
114+
},
115+
Status: v1alpha1.StepStatusUnknown,
116+
}},
117+
bundleLookups: []v1alpha1.BundleLookup{
118+
{
119+
Identifier: "csvA",
120+
},
121+
},
122+
expectedClusterServiceVersionNames: []string{"csvA"},
123+
},
124+
}
125+
for _, tt := range tests {
126+
t.Run(tt.testName, func(t *testing.T) {
127+
ctx, cancel := context.WithCancel(context.TODO())
128+
defer cancel()
129+
130+
op, err := NewFakeOperator(ctx, namespace, []string{namespace})
131+
require.NoError(t, err)
132+
133+
_, err = op.createInstallPlan(namespace, 0, nil, v1alpha1.ApprovalAutomatic, tt.steps, tt.bundleLookups)
134+
require.NoError(t, err)
135+
136+
ipList, err := op.client.OperatorsV1alpha1().InstallPlans(namespace).List(ctx, metav1.ListOptions{})
137+
require.NoError(t, err)
138+
require.Len(t, ipList.Items, 1)
139+
require.Equal(t, tt.expectedClusterServiceVersionNames, ipList.Items[0].Spec.ClusterServiceVersionNames)
140+
})
141+
}
142+
}
143+
80144
func TestTransitionInstallPlan(t *testing.T) {
81145
errMsg := "transition test error"
82146
err := errors.New(errMsg)

vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/controller/operators/catalog/operator.go

Lines changed: 1 addition & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)