Skip to content

Commit f749c5a

Browse files
committed
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 fdfda1e commit f749c5a

File tree

2 files changed

+68
-9
lines changed

2 files changed

+68
-9
lines changed

pkg/controller/registry/resolver/resolver.go

+1-9
Original file line numberDiff line numberDiff line change
@@ -324,15 +324,7 @@ func (r *SatResolver) getBundleInstallables(catalog registry.CatalogKey, predica
324324
continue
325325
}
326326
bundleDependencies := make([]solver.Identifier, 0)
327-
for _, dep := range sortedBundles {
328-
found := namespacedCache.Catalog(dep.SourceInfo().Catalog).Find(WithCSVName(dep.Identifier()))
329-
if len(found) == 0 {
330-
err := fmt.Errorf("couldn't find %s in %s", bundle.Identifier(), dep.sourceInfo.Catalog)
331-
errs = append(errs, err)
332-
r.log.Warnf("cache consistency error: %s not found in %s", bundle.Identifier(), dep.sourceInfo.Catalog)
333-
continue
334-
}
335-
b := found[0]
327+
for _, b := range sortedBundles {
336328
src := b.SourceInfo()
337329
if src == nil {
338330
err := fmt.Errorf("unable to resolve the source of bundle %s, invalid cache", bundle.Identifier())

test/e2e/subscription_e2e_test.go

+67
Original file line numberDiff line numberDiff line change
@@ -2063,6 +2063,73 @@ var _ = Describe("Subscription", func() {
20632063
}).ShouldNot(Succeed())
20642064
})
20652065
})
2066+
2067+
When("there exists a Subscription to an operator having dependency candidates in both default and nondefault channels", func() {
2068+
var (
2069+
teardown func()
2070+
)
2071+
2072+
BeforeEach(func() {
2073+
teardown = func() {}
2074+
2075+
packages := []registry.PackageManifest{
2076+
{
2077+
PackageName: "dependency",
2078+
Channels: []registry.PackageChannel{
2079+
{Name: "default", CurrentCSVName: "csv-dependency"},
2080+
{Name: "nondefault", CurrentCSVName: "csv-dependency"},
2081+
},
2082+
DefaultChannelName: "default",
2083+
},
2084+
{
2085+
PackageName: "root",
2086+
Channels: []registry.PackageChannel{
2087+
{Name: "unimportant", CurrentCSVName: "csv-root"},
2088+
},
2089+
DefaultChannelName: "unimportant",
2090+
},
2091+
}
2092+
2093+
crds := []apiextensions.CustomResourceDefinition{newCRD(genName("crd-"))}
2094+
csvs := []operatorsv1alpha1.ClusterServiceVersion{
2095+
newCSV("csv-dependency", testNamespace, "", semver.MustParse("1.0.0"), crds, nil, nil),
2096+
newCSV("csv-root", testNamespace, "", semver.MustParse("1.0.0"), nil, crds, nil),
2097+
}
2098+
2099+
_, teardown = createInternalCatalogSource(ctx.Ctx().KubeClient(), ctx.Ctx().OperatorClient(), "test-catalog", testNamespace, packages, crds, csvs)
2100+
2101+
createSubscriptionForCatalog(ctx.Ctx().OperatorClient(), testNamespace, "test-subscription", "test-catalog", "root", "unimportant", "", operatorsv1alpha1.ApprovalAutomatic)
2102+
})
2103+
2104+
AfterEach(func() {
2105+
teardown()
2106+
})
2107+
2108+
It("should create a Subscription using the candidate's default channel", func() {
2109+
Eventually(func() ([]operatorsv1alpha1.Subscription, error) {
2110+
var list operatorsv1alpha1.SubscriptionList
2111+
if err := ctx.Ctx().Client().List(context.TODO(), &list); err != nil {
2112+
return nil, err
2113+
}
2114+
return list.Items, nil
2115+
}).Should(ContainElement(WithTransform(
2116+
func(in operatorsv1alpha1.Subscription) operatorsv1alpha1.SubscriptionSpec {
2117+
return operatorsv1alpha1.SubscriptionSpec{
2118+
CatalogSource: in.Spec.CatalogSource,
2119+
CatalogSourceNamespace: in.Spec.CatalogSourceNamespace,
2120+
Package: in.Spec.Package,
2121+
Channel: in.Spec.Channel,
2122+
}
2123+
},
2124+
Equal(operatorsv1alpha1.SubscriptionSpec{
2125+
CatalogSource: "test-catalog",
2126+
CatalogSourceNamespace: testNamespace,
2127+
Package: "dependency",
2128+
Channel: "default",
2129+
}),
2130+
)))
2131+
})
2132+
})
20662133
})
20672134

20682135
const (

0 commit comments

Comments
 (0)