Skip to content

Commit 39635f4

Browse files
benluddyopenshift-cherrypick-robot
authored andcommitted
Fix inconsistent dependency candidate order.
After bundle dependency candidates are sorted, a second query is made to the catalog cache. This query filters by CSV name alone, so it's ambiguous when the same CSV name appears in multiple channels (or packages). The query appears to be redundant, so it has been removed. Signed-off-by: Ben Luddy <[email protected]>
1 parent bf72c5d commit 39635f4

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

test/e2e/subscription_e2e_test.go

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2131,6 +2131,73 @@ var _ = Describe("Subscription", func() {
21312131
}).ShouldNot(Succeed())
21322132
})
21332133
})
2134+
2135+
When("there exists a Subscription to an operator having dependency candidates in both default and nondefault channels", func() {
2136+
var (
2137+
teardown func()
2138+
)
2139+
2140+
BeforeEach(func() {
2141+
teardown = func() {}
2142+
2143+
packages := []registry.PackageManifest{
2144+
{
2145+
PackageName: "dependency",
2146+
Channels: []registry.PackageChannel{
2147+
{Name: "default", CurrentCSVName: "csv-dependency"},
2148+
{Name: "nondefault", CurrentCSVName: "csv-dependency"},
2149+
},
2150+
DefaultChannelName: "default",
2151+
},
2152+
{
2153+
PackageName: "root",
2154+
Channels: []registry.PackageChannel{
2155+
{Name: "unimportant", CurrentCSVName: "csv-root"},
2156+
},
2157+
DefaultChannelName: "unimportant",
2158+
},
2159+
}
2160+
2161+
crds := []apiextensions.CustomResourceDefinition{newCRD(genName("crd-"))}
2162+
csvs := []operatorsv1alpha1.ClusterServiceVersion{
2163+
newCSV("csv-dependency", testNamespace, "", semver.MustParse("1.0.0"), crds, nil, nil),
2164+
newCSV("csv-root", testNamespace, "", semver.MustParse("1.0.0"), nil, crds, nil),
2165+
}
2166+
2167+
_, teardown = createInternalCatalogSource(ctx.Ctx().KubeClient(), ctx.Ctx().OperatorClient(), "test-catalog", testNamespace, packages, crds, csvs)
2168+
2169+
createSubscriptionForCatalog(ctx.Ctx().OperatorClient(), testNamespace, "test-subscription", "test-catalog", "root", "unimportant", "", operatorsv1alpha1.ApprovalAutomatic)
2170+
})
2171+
2172+
AfterEach(func() {
2173+
teardown()
2174+
})
2175+
2176+
It("should create a Subscription using the candidate's default channel", func() {
2177+
Eventually(func() ([]operatorsv1alpha1.Subscription, error) {
2178+
var list operatorsv1alpha1.SubscriptionList
2179+
if err := ctx.Ctx().Client().List(context.TODO(), &list); err != nil {
2180+
return nil, err
2181+
}
2182+
return list.Items, nil
2183+
}).Should(ContainElement(WithTransform(
2184+
func(in operatorsv1alpha1.Subscription) operatorsv1alpha1.SubscriptionSpec {
2185+
return operatorsv1alpha1.SubscriptionSpec{
2186+
CatalogSource: in.Spec.CatalogSource,
2187+
CatalogSourceNamespace: in.Spec.CatalogSourceNamespace,
2188+
Package: in.Spec.Package,
2189+
Channel: in.Spec.Channel,
2190+
}
2191+
},
2192+
Equal(operatorsv1alpha1.SubscriptionSpec{
2193+
CatalogSource: "test-catalog",
2194+
CatalogSourceNamespace: testNamespace,
2195+
Package: "dependency",
2196+
Channel: "default",
2197+
}),
2198+
)))
2199+
})
2200+
})
21342201
})
21352202

21362203
const (

0 commit comments

Comments
 (0)