Skip to content

Commit 7fa4293

Browse files
committed
resolver: remove legacy support for fallback parsing of CSVs
When no APIs or properties are present on bundles, the resolver currently falls back to a legacy mode where that information is parsed from CSVs present in the index. This legacy fallback method causes the resolver to incorrectly identify multiple heads for a channel when: a) The index contains CSVs only on channel head bundles, and b) A package contains two channels, where one channel contains the head of the other channel and there is at least one other node between these channel head nodes in that channel. c) The bundles have no properties, provided APIs, or required APIs Conditions a) and b) are extremely prevalent, so this bug will often be encountered whenever c) itself is true. This commit removes support for the legacy CSV parsing fallback, which means that only first class fields in the GRPC API will be used during resolutions. Signed-off-by: Joe Lanford <[email protected]>
1 parent 7fe8851 commit 7fa4293

File tree

2 files changed

+8
-120
lines changed

2 files changed

+8
-120
lines changed

pkg/controller/registry/resolver/operators.go

-25
Original file line numberDiff line numberDiff line change
@@ -278,31 +278,6 @@ func NewOperatorFromBundle(bundle *api.Bundle, startingCSV string, sourceKey reg
278278
properties = append(properties, ps...)
279279
}
280280

281-
// legacy support - if the grpc api doesn't contain required/provided apis, fallback to csv parsing
282-
if len(required) == 0 && len(provided) == 0 && len(properties) == 0 {
283-
// fallback to csv parsing
284-
if bundle.CsvJson == "" {
285-
if bundle.GetBundlePath() != "" {
286-
return nil, fmt.Errorf("couldn't parse bundle path, missing provided and required apis")
287-
}
288-
289-
return nil, fmt.Errorf("couldn't parse bundle, missing provided and required apis")
290-
}
291-
292-
csv := &v1alpha1.ClusterServiceVersion{}
293-
if err := json.Unmarshal([]byte(bundle.CsvJson), csv); err != nil {
294-
return nil, err
295-
}
296-
297-
op, err := NewOperatorFromV1Alpha1CSV(csv)
298-
if err != nil {
299-
return nil, err
300-
}
301-
op.sourceInfo = sourceInfo
302-
op.bundle = bundle
303-
return op, nil
304-
}
305-
306281
o := &Operator{
307282
name: bundle.CsvName,
308283
replaces: bundle.Replaces,

pkg/controller/registry/resolver/operators_test.go

+8-95
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@ import (
44
"encoding/json"
55
"testing"
66

7-
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry"
8-
97
"github.com/blang/semver/v4"
108
"github.com/stretchr/testify/require"
119
"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
1210
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1311

1412
opver "github.com/operator-framework/api/pkg/lib/version"
1513
"github.com/operator-framework/api/pkg/operators/v1alpha1"
14+
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry"
1615
"github.com/operator-framework/operator-registry/pkg/api"
1716
opregistry "github.com/operator-framework/operator-registry/pkg/registry"
1817
)
@@ -1078,8 +1077,7 @@ func TestNewOperatorFromBundle(t *testing.T) {
10781077
sourceKey: registry.CatalogKey{Name: "source", Namespace: "testNamespace"},
10791078
},
10801079
want: &Operator{
1081-
// lack of full api response falls back to csv name
1082-
name: "testCSV",
1080+
name: "testBundle",
10831081
version: &version.Version,
10841082
providedAPIs: EmptyAPISet(),
10851083
requiredAPIs: EmptyAPISet(),
@@ -1155,81 +1153,16 @@ func TestNewOperatorFromBundle(t *testing.T) {
11551153
},
11561154
},
11571155
{
1158-
name: "BundleReplaceOverrides",
1156+
name: "BundleIgnoreCSV",
11591157
args: args{
1160-
bundle: bundleNoAPIs,
1158+
bundle: bundleWithAPIsUnextracted,
11611159
sourceKey: registry.CatalogKey{Name: "source", Namespace: "testNamespace"},
11621160
},
11631161
want: &Operator{
1164-
// lack of full api response falls back to csv name
1165-
name: "testCSV",
1162+
name: "testBundle",
11661163
providedAPIs: EmptyAPISet(),
11671164
requiredAPIs: EmptyAPISet(),
1168-
bundle: bundleNoAPIs,
1169-
version: &version.Version,
1170-
sourceInfo: &OperatorSourceInfo{
1171-
Package: "testPackage",
1172-
Channel: "testChannel",
1173-
Catalog: registry.CatalogKey{Name: "source", Namespace: "testNamespace"},
1174-
},
1175-
},
1176-
},
1177-
{
1178-
name: "BundleCsvFallback",
1179-
args: args{
1180-
bundle: bundleWithAPIsUnextracted,
1181-
sourceKey: registry.CatalogKey{Name: "source", Namespace: "testNamespace"},
1182-
},
1183-
want: &Operator{
1184-
name: "testCSV",
1185-
providedAPIs: APISet{
1186-
opregistry.APIKey{
1187-
Group: "crd.group.com",
1188-
Version: "v1",
1189-
Kind: "OwnedCRD",
1190-
Plural: "owneds",
1191-
}: struct{}{},
1192-
opregistry.APIKey{
1193-
Group: "apis.group.com",
1194-
Version: "v1",
1195-
Kind: "OwnedAPI",
1196-
Plural: "ownedapis",
1197-
}: struct{}{},
1198-
},
1199-
requiredAPIs: APISet{
1200-
opregistry.APIKey{
1201-
Group: "crd.group.com",
1202-
Version: "v1",
1203-
Kind: "RequiredCRD",
1204-
Plural: "requireds",
1205-
}: struct{}{},
1206-
opregistry.APIKey{
1207-
Group: "apis.group.com",
1208-
Version: "v1",
1209-
Kind: "RequiredAPI",
1210-
Plural: "requiredapis",
1211-
}: struct{}{},
1212-
},
1213-
properties: []*api.Property{
1214-
{
1215-
Type: "olm.gvk",
1216-
Value: "{\"group\":\"crd.group.com\",\"kind\":\"OwnedCRD\",\"version\":\"v1\"}",
1217-
},
1218-
{
1219-
Type: "olm.gvk",
1220-
Value: "{\"group\":\"apis.group.com\",\"kind\":\"OwnedAPI\",\"version\":\"v1\"}",
1221-
},
1222-
{
1223-
Type: "olm.gvk.required",
1224-
Value: "{\"group\":\"apis.group.com\",\"kind\":\"RequiredAPI\",\"version\":\"v1\"}",
1225-
},
1226-
{
1227-
Type: "olm.gvk.required",
1228-
Value: "{\"group\":\"crd.group.com\",\"kind\":\"RequiredCRD\",\"version\":\"v1\"}",
1229-
},
1230-
},
1231-
bundle: bundleWithAPIsUnextracted,
1232-
version: &version.Version,
1165+
bundle: bundleWithAPIsUnextracted,
12331166
sourceInfo: &OperatorSourceInfo{
12341167
Package: "testPackage",
12351168
Channel: "testChannel",
@@ -1238,14 +1171,14 @@ func TestNewOperatorFromBundle(t *testing.T) {
12381171
},
12391172
},
12401173
{
1241-
name: "bundle in default channel",
1174+
name: "BundleInDefaultChannel",
12421175
args: args{
12431176
bundle: bundleNoAPIs,
12441177
sourceKey: registry.CatalogKey{Name: "source", Namespace: "testNamespace"},
12451178
defaultChannel: "testChannel",
12461179
},
12471180
want: &Operator{
1248-
name: "testCSV",
1181+
name: "testBundle",
12491182
version: &version.Version,
12501183
providedAPIs: EmptyAPISet(),
12511184
requiredAPIs: EmptyAPISet(),
@@ -1258,26 +1191,6 @@ func TestNewOperatorFromBundle(t *testing.T) {
12581191
},
12591192
},
12601193
},
1261-
{
1262-
name: "BundleNoAPIs",
1263-
args: args{
1264-
bundle: bundleNoAPIs,
1265-
sourceKey: registry.CatalogKey{Name: "source", Namespace: "testNamespace"},
1266-
},
1267-
want: &Operator{
1268-
// lack of full api response falls back to csv name
1269-
name: "testCSV",
1270-
version: &version.Version,
1271-
providedAPIs: EmptyAPISet(),
1272-
requiredAPIs: EmptyAPISet(),
1273-
bundle: bundleNoAPIs,
1274-
sourceInfo: &OperatorSourceInfo{
1275-
Package: "testPackage",
1276-
Channel: "testChannel",
1277-
Catalog: registry.CatalogKey{Name: "source", Namespace: "testNamespace"},
1278-
},
1279-
},
1280-
},
12811194
{
12821195
name: "BundleWithPropertiesAndDependencies",
12831196
args: args{

0 commit comments

Comments
 (0)