Skip to content

Commit 48119fa

Browse files
ecordellopenshift-cherrypick-robot
authored andcommitted
fix(bundles): include csv name in installplan for bundle images
this fixes a bug where operators installed via images where not detected as part of the installplan, and install would fail
1 parent 6a79732 commit 48119fa

File tree

6 files changed

+15
-3
lines changed

6 files changed

+15
-3
lines changed

pkg/api/apis/operators/installplan_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ type BundleLookup struct {
199199
// Path refers to the location of a bundle to pull.
200200
// It's typically an image reference.
201201
Path string
202+
// Identifier is the catalog-unique name of the operator (the name of the CSV for bundles that contain CSVs)
203+
Identifier string
202204
// Replaces is the name of the bundle to replace with the one found at Path.
203205
Replaces string
204206
// CatalogSourceRef is a reference to the CatalogSource the bundle path was resolved from.

pkg/api/apis/operators/v1alpha1/installplan_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@ type BundleLookup struct {
252252
// Path refers to the location of a bundle to pull.
253253
// It's typically an image reference.
254254
Path string `json:"path"`
255+
// Identifier is the catalog-unique name of the operator (the name of the CSV for bundles that contain CSVs)
256+
Identifier string `json:"identifier"`
255257
// Replaces is the name of the bundle to replace with the one found at Path.
256258
Replaces string `json:"replaces"`
257259
// CatalogSourceRef is a reference to the CatalogSource the bundle path was resolved from.

pkg/controller/operators/catalog/operator.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,6 +1022,9 @@ func (o *Operator) createInstallPlan(namespace string, gen int, subs []*v1alpha1
10221022
}
10231023
catalogSourceMap[s.Resource.CatalogSource] = struct{}{}
10241024
}
1025+
for _, b := range bundleLookups {
1026+
csvNames = append(csvNames, b.Identifier)
1027+
}
10251028
catalogSources := []string{}
10261029
for s := range catalogSourceMap {
10271030
catalogSources = append(catalogSources, s)

pkg/controller/operators/catalog/subscriptions_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ func TestSyncSubscriptions(t *testing.T) {
378378
bundleLookups: []v1alpha1.BundleLookup{
379379
{
380380
Path: "bundle-path-a",
381+
Identifier: "bundle-a",
381382
CatalogSourceRef: &corev1.ObjectReference{
382383
Namespace: testNamespace,
383384
Name: "src",
@@ -447,7 +448,7 @@ func TestSyncSubscriptions(t *testing.T) {
447448
},
448449
wantInstallPlan: &v1alpha1.InstallPlan{
449450
Spec: v1alpha1.InstallPlanSpec{
450-
ClusterServiceVersionNames: []string{},
451+
ClusterServiceVersionNames: []string{"bundle-a"},
451452
Approval: v1alpha1.ApprovalAutomatic,
452453
Approved: true,
453454
Generation: 1,
@@ -458,6 +459,7 @@ func TestSyncSubscriptions(t *testing.T) {
458459
BundleLookups: []v1alpha1.BundleLookup{
459460
{
460461
Path: "bundle-path-a",
462+
Identifier: "bundle-a",
461463
CatalogSourceRef: &corev1.ObjectReference{
462464
Namespace: testNamespace,
463465
Name: "src",

pkg/controller/registry/resolver/resolver.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,9 @@ func (r *OperatorsV1alpha1Resolver) ResolveSteps(namespace string, sourceQuerier
109109
steps = append(steps, bundleSteps...)
110110
} else {
111111
bundleLookups = append(bundleLookups, v1alpha1.BundleLookup{
112-
Path: op.Bundle().GetBundlePath(),
113-
Replaces: op.Replaces(),
112+
Path: op.Bundle().GetBundlePath(),
113+
Identifier: op.Identifier(),
114+
Replaces: op.Replaces(),
114115
CatalogSourceRef: &corev1.ObjectReference{
115116
Namespace: op.SourceInfo().Catalog.Namespace,
116117
Name: op.SourceInfo().Catalog.Name,

pkg/controller/registry/resolver/resolver_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ func TestNamespaceResolver(t *testing.T) {
121121
lookups: []v1alpha1.BundleLookup{
122122
{
123123
Path: "quay.io/test/bundle@sha256:abcd",
124+
Identifier: "b.v1",
124125
CatalogSourceRef: &corev1.ObjectReference{
125126
Namespace: catalog.Namespace,
126127
Name: catalog.Name,
@@ -234,6 +235,7 @@ func TestNamespaceResolver(t *testing.T) {
234235
lookups: []v1alpha1.BundleLookup{
235236
{
236237
Path: "quay.io/test/bundle@sha256:abcd",
238+
Identifier: "a.v2",
237239
Replaces: "a.v1",
238240
CatalogSourceRef: &corev1.ObjectReference{
239241
Namespace: catalog.Namespace,

0 commit comments

Comments
 (0)