From 514c1a2052c1291b16b19b0ca3d6e6a9062426cd Mon Sep 17 00:00:00 2001 From: Sid Kattoju Date: Mon, 9 Sep 2024 09:47:28 -0400 Subject: [PATCH 1/2] more descriptive upgrade contstraint policy constants --- api/v1alpha1/clusterextension_types.go | 16 ++--- ...peratorframework.io_clusterextensions.yaml | 14 ++-- docs/drafts/upgrade-support.md | 16 ++--- .../api/operator-controller-api-reference.md | 6 +- internal/resolve/catalog.go | 2 +- internal/resolve/catalog_test.go | 66 +++++++++---------- test/e2e/cluster_extension_install_test.go | 2 +- 7 files changed, 61 insertions(+), 61 deletions(-) diff --git a/api/v1alpha1/clusterextension_types.go b/api/v1alpha1/clusterextension_types.go index 645a069fb..d6f766f8a 100644 --- a/api/v1alpha1/clusterextension_types.go +++ b/api/v1alpha1/clusterextension_types.go @@ -33,7 +33,7 @@ type CRDUpgradeSafetyPolicy string const ( // The extension will only upgrade if the new version satisfies // the upgrade constraints set by the package author. - UpgradeConstraintPolicyEnforce UpgradeConstraintPolicy = "Enforce" + UpgradeConstraintPolicyCatalogProvided UpgradeConstraintPolicy = "CatalogProvided" // Unsafe option which allows an extension to be // upgraded or downgraded to any available version of the package and @@ -41,7 +41,7 @@ const ( // This assumes that users independently verify the outcome of the changes. // Use with caution as this can lead to unknown and potentially // disastrous results such as data loss. - UpgradeConstraintPolicyIgnore UpgradeConstraintPolicy = "Ignore" + UpgradeConstraintPolicySelfCertified UpgradeConstraintPolicy = "SelfCertified" ) // ClusterExtensionSpec defines the desired state of ClusterExtension @@ -323,22 +323,22 @@ type CatalogSource struct { // the upgrade path(s) defined in the catalog are enforced for the package // referenced in the packageName field. // - // Allowed values are: ["Enforce", "Ignore"]. + // Allowed values are: ["CatalogProvided", "SelfCertified"]. // - // When this field is set to "Enforce", automatic upgrades will only occur + // When this field is set to "CatalogProvided", automatic upgrades will only occur // when upgrade constraints specified by the package author are met. // - // When this field is set to "Ignore", the upgrade constraints specified by + // When this field is set to "SelfCertified", the upgrade constraints specified by // the package author are ignored. This allows for upgrades and downgrades to // any version of the package. This is considered a dangerous operation as it // can lead to unknown and potentially disastrous outcomes, such as data // loss. It is assumed that users have independently verified changes when // using this option. // - // If unspecified, the default value is "Enforce". + // If unspecified, the default value is "CatalogProvided". // - //+kubebuilder:validation:Enum:=Enforce;Ignore - //+kubebuilder:default:=Enforce + //+kubebuilder:validation:Enum:=CatalogProvided;SelfCertified + //+kubebuilder:default:=CatalogProvided //+optional UpgradeConstraintPolicy UpgradeConstraintPolicy `json:"upgradeConstraintPolicy,omitempty"` } diff --git a/config/base/crd/bases/olm.operatorframework.io_clusterextensions.yaml b/config/base/crd/bases/olm.operatorframework.io_clusterextensions.yaml index a10aea93e..f66b309c3 100644 --- a/config/base/crd/bases/olm.operatorframework.io_clusterextensions.yaml +++ b/config/base/crd/bases/olm.operatorframework.io_clusterextensions.yaml @@ -330,28 +330,28 @@ spec: type: object x-kubernetes-map-type: atomic upgradeConstraintPolicy: - default: Enforce + default: CatalogProvided description: |- upgradeConstraintPolicy is an optional field that controls whether the upgrade path(s) defined in the catalog are enforced for the package referenced in the packageName field. - Allowed values are: ["Enforce", "Ignore"]. + Allowed values are: ["CatalogProvided", "SelfCertified"]. - When this field is set to "Enforce", automatic upgrades will only occur + When this field is set to "CatalogProvided", automatic upgrades will only occur when upgrade constraints specified by the package author are met. - When this field is set to "Ignore", the upgrade constraints specified by + When this field is set to "SelfCertified", the upgrade constraints specified by the package author are ignored. This allows for upgrades and downgrades to any version of the package. This is considered a dangerous operation as it can lead to unknown and potentially disastrous outcomes, such as data loss. It is assumed that users have independently verified changes when using this option. - If unspecified, the default value is "Enforce". + If unspecified, the default value is "CatalogProvided". enum: - - Enforce - - Ignore + - CatalogProvided + - SelfCertified type: string version: description: |- diff --git a/docs/drafts/upgrade-support.md b/docs/drafts/upgrade-support.md index 418fbb44b..367a57ec1 100644 --- a/docs/drafts/upgrade-support.md +++ b/docs/drafts/upgrade-support.md @@ -42,17 +42,17 @@ spec: packageName: serviceAccount: name: - upgradeConstraintPolicy: Ignore + upgradeConstraintPolicy: SelfCertified version: "" ``` where setting the `upgradeConstraintPolicy` to: -`Ignore` +`SelfCertified` : Does not limit the next version to the set of successors, and instead allows for any downgrade, sidegrade, or upgrade. -`Enforce` -: Only allows the next version to come from the successors list. This is the default value. If the `upgradeConstraintPolicy` parameter is not defined in an extension's CR, then the policy is set to `Enforce` by default. +`CatalogProvided` +: Only allows the next version to come from the successors list. This is the default value. If the `upgradeConstraintPolicy` parameter is not defined in an extension's CR, then the policy is set to `CatalogProvided` by default. ## Upgrades @@ -74,11 +74,11 @@ You must verify and perform upgrades manually in cases where automatic upgrades **Warning:** If you want to force an upgrade manually, you must thoroughly verify the outcome before applying any changes to production workloads. Failure to test and verify the upgrade might lead to catastrophic consequences such as data loss. -As a package admin, if you must upgrade or downgrade to version that might be incompatible with the currently installed version, you can set the `.spec.upgradeConstraintPolicy` field to `Ignore` on the relevant `ClusterExtension` resource. +As a package admin, if you must upgrade or downgrade to version that might be incompatible with the currently installed version, you can set the `.spec.upgradeConstraintPolicy` field to `SelfCertified` on the relevant `ClusterExtension` resource. -If you set the field to `Ignore`, no upgrade constraints are set on the package. As a result, you can change the version to any version available in the catalogs for a given package. +If you set the field to `SelfCertified`, no upgrade constraints are set on the package. As a result, you can change the version to any version available in the catalogs for a given package. -Example `ClusterExtension` with `.spec.upgradeConstraintPolicy` field set to `Ignore`: +Example `ClusterExtension` with `.spec.upgradeConstraintPolicy` field set to `SelfCertified`: ```yaml apiVersion: olm.operatorframework.io/v1alpha1 @@ -91,7 +91,7 @@ spec: catalog: packageName: argocd-operator version: 0.6.0 - upgradeConstraintPolicy: Ignore + upgradeConstraintPolicy: SelfCertified install: namespace: argocd serviceAccout: diff --git a/docs/refs/api/operator-controller-api-reference.md b/docs/refs/api/operator-controller-api-reference.md index 56c92183e..2b4f51db9 100644 --- a/docs/refs/api/operator-controller-api-reference.md +++ b/docs/refs/api/operator-controller-api-reference.md @@ -82,7 +82,7 @@ _Appears in:_ | `version` _string_ | version is an optional semver constraint (a specific version or range of versions). When unspecified, the latest version available will be installed.

Acceptable version ranges are no longer than 64 characters.
Version ranges are composed of comma- or space-delimited values and one or
more comparison operators, known as comparison strings. Additional
comparison strings can be added using the OR operator (\|\|).

# Range Comparisons

To specify a version range, you can use a comparison string like ">=3.0,
<3.6". When specifying a range, automatic updates will occur within that
range. The example comparison string means "install any version greater than
or equal to 3.0.0 but less than 3.6.0.". It also states intent that if any
upgrades are available within the version range after initial installation,
those upgrades should be automatically performed.

# Pinned Versions

To specify an exact version to install you can use a version range that
"pins" to a specific version. When pinning to a specific version, no
automatic updates will occur. An example of a pinned version range is
"0.6.0", which means "only install version 0.6.0 and never
upgrade from this version".

# Basic Comparison Operators

The basic comparison operators and their meanings are:
- "=", equal (not aliased to an operator)
- "!=", not equal
- "<", less than
- ">", greater than
- ">=", greater than OR equal to
- "<=", less than OR equal to

# Wildcard Comparisons

You can use the "x", "X", and "*" characters as wildcard characters in all
comparison operations. Some examples of using the wildcard characters:
- "1.2.x", "1.2.X", and "1.2.*" is equivalent to ">=1.2.0, < 1.3.0"
- ">= 1.2.x", ">= 1.2.X", and ">= 1.2.*" is equivalent to ">= 1.2.0"
- "<= 2.x", "<= 2.X", and "<= 2.*" is equivalent to "< 3"
- "x", "X", and "*" is equivalent to ">= 0.0.0"

# Patch Release Comparisons

When you want to specify a minor version up to the next major version you
can use the "~" character to perform patch comparisons. Some examples:
- "~1.2.3" is equivalent to ">=1.2.3, <1.3.0"
- "~1" and "~1.x" is equivalent to ">=1, <2"
- "~2.3" is equivalent to ">=2.3, <2.4"
- "~1.2.x" is equivalent to ">=1.2.0, <1.3.0"

# Major Release Comparisons

You can use the "^" character to make major release comparisons after a
stable 1.0.0 version is published. If there is no stable version published, // minor versions define the stability level. Some examples:
- "^1.2.3" is equivalent to ">=1.2.3, <2.0.0"
- "^1.2.x" is equivalent to ">=1.2.0, <2.0.0"
- "^2.3" is equivalent to ">=2.3, <3"
- "^2.x" is equivalent to ">=2.0.0, <3"
- "^0.2.3" is equivalent to ">=0.2.3, <0.3.0"
- "^0.2" is equivalent to ">=0.2.0, <0.3.0"
- "^0.0.3" is equvalent to ">=0.0.3, <0.0.4"
- "^0.0" is equivalent to ">=0.0.0, <0.1.0"
- "^0" is equivalent to ">=0.0.0, <1.0.0"

# OR Comparisons
You can use the "\|\|" character to represent an OR operation in the version
range. Some examples:
- ">=1.2.3, <2.0.0 \|\| >3.0.0"
- "^0 \|\| ^3 \|\| ^5"

For more information on semver, please see https://semver.org/ | | MaxLength: 64
Pattern: `^(\s*(=\|\|!=\|>\|<\|>=\|=>\|<=\|=<\|~\|~>\|\^)\s*(v?(0\|[1-9]\d*\|[x\|X\|\*])(\.(0\|[1-9]\d*\|x\|X\|\*]))?(\.(0\|[1-9]\d*\|x\|X\|\*))?(-([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?(\+([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?)\s*)((?:\s+\|,\s*\|\s*\\|\\|\s*)(=\|\|!=\|>\|<\|>=\|=>\|<=\|=<\|~\|~>\|\^)\s*(v?(0\|[1-9]\d*\|x\|X\|\*])(\.(0\|[1-9]\d*\|x\|X\|\*))?(\.(0\|[1-9]\d*\|x\|X\|\*]))?(-([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?(\+([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?)\s*)*$`
| | `channels` _string array_ | channels is an optional reference to a set of channels belonging to
the package specified in the packageName field.

A "channel" is a package author defined stream of updates for an extension.

When specified, it is used to constrain the set of installable bundles and
the automated upgrade path. This constraint is an AND operation with the
version field. For example:
- Given channel is set to "foo"
- Given version is set to ">=1.0.0, <1.5.0"
- Only bundles that exist in channel "foo" AND satisfy the version range comparison will be considered installable
- Automatic upgrades will be constrained to upgrade edges defined by the selected channel

When unspecified, upgrade edges across all channels will be used to identify valid automatic upgrade paths.

This field follows the DNS subdomain name standard as defined in [RFC
1123]. This means that valid entries:
- Contain no more than 253 characters
- Contain only lowercase alphanumeric characters, '-', or '.'
- Start with an alphanumeric character
- End with an alphanumeric character

Some examples of valid values are:
- 1.1.x
- alpha
- stable
- stable-v1
- v1-stable
- dev-preview
- preview
- community

Some examples of invalid values are:
- -some-channel
- some-channel-
- thisisareallylongchannelnamethatisgreaterthanthemaximumlength
- original_40
- --default-channel

[RFC 1123]: https://tools.ietf.org/html/rfc1123 | | | | `selector` _[LabelSelector](https://kubernetes.io/docs/reference/generated/kubernetes-api/v/#labelselector-v1-meta)_ | selector is an optional field that can be used
to filter the set of ClusterCatalogs used in the bundle
selection process.

When unspecified, all ClusterCatalogs will be used in
the bundle selection process. | | | -| `upgradeConstraintPolicy` _[UpgradeConstraintPolicy](#upgradeconstraintpolicy)_ | upgradeConstraintPolicy is an optional field that controls whether
the upgrade path(s) defined in the catalog are enforced for the package
referenced in the packageName field.

Allowed values are: ["Enforce", "Ignore"].

When this field is set to "Enforce", automatic upgrades will only occur
when upgrade constraints specified by the package author are met.

When this field is set to "Ignore", the upgrade constraints specified by
the package author are ignored. This allows for upgrades and downgrades to
any version of the package. This is considered a dangerous operation as it
can lead to unknown and potentially disastrous outcomes, such as data
loss. It is assumed that users have independently verified changes when
using this option.

If unspecified, the default value is "Enforce". | Enforce | Enum: [Enforce Ignore]
| +| `upgradeConstraintPolicy` _[UpgradeConstraintPolicy](#upgradeconstraintpolicy)_ | upgradeConstraintPolicy is an optional field that controls whether
the upgrade path(s) defined in the catalog are enforced for the package
referenced in the packageName field.

Allowed values are: ["CatalogProvided", "SelfCertified"].

When this field is set to "CatalogProvided", automatic upgrades will only occur
when upgrade constraints specified by the package author are met.

When this field is set to "SelfCertified", the upgrade constraints specified by
the package author are ignored. This allows for upgrades and downgrades to
any version of the package. This is considered a dangerous operation as it
can lead to unknown and potentially disastrous outcomes, such as data
loss. It is assumed that users have independently verified changes when
using this option.

If unspecified, the default value is "CatalogProvided". | CatalogProvided | Enum: [CatalogProvided SelfCertified]
| #### ClusterExtension @@ -275,7 +275,7 @@ _Appears in:_ | Field | Description | | --- | --- | -| `Enforce` | The extension will only upgrade if the new version satisfies
the upgrade constraints set by the package author.
| -| `Ignore` | Unsafe option which allows an extension to be
upgraded or downgraded to any available version of the package and
ignore the upgrade path designed by package authors.
This assumes that users independently verify the outcome of the changes.
Use with caution as this can lead to unknown and potentially
disastrous results such as data loss.
| +| `CatalogProvided` | The extension will only upgrade if the new version satisfies
the upgrade constraints set by the package author.
| +| `SelfCertified` | Unsafe option which allows an extension to be
upgraded or downgraded to any available version of the package and
ignore the upgrade path designed by package authors.
This assumes that users independently verify the outcome of the changes.
Use with caution as this can lead to unknown and potentially
disastrous results such as data loss.
| diff --git a/internal/resolve/catalog.go b/internal/resolve/catalog.go index 83857a8fe..17439269e 100644 --- a/internal/resolve/catalog.go +++ b/internal/resolve/catalog.go @@ -83,7 +83,7 @@ func (r *CatalogResolver) Resolve(ctx context.Context, ext *ocv1alpha1.ClusterEx predicates = append(predicates, filter.InMastermindsSemverRange(versionRangeConstraints)) } - if ext.Spec.Source.Catalog.UpgradeConstraintPolicy != ocv1alpha1.UpgradeConstraintPolicyIgnore && installedBundle != nil { + if ext.Spec.Source.Catalog.UpgradeConstraintPolicy != ocv1alpha1.UpgradeConstraintPolicySelfCertified && installedBundle != nil { successorPredicate, err := filter.SuccessorsOf(installedBundle, packageFBC.Channels...) if err != nil { return fmt.Errorf("error finding upgrade edges: %w", err) diff --git a/internal/resolve/catalog_test.go b/internal/resolve/catalog_test.go index 4a6c522d4..8746fc62d 100644 --- a/internal/resolve/catalog_test.go +++ b/internal/resolve/catalog_test.go @@ -27,7 +27,7 @@ import ( func TestInvalidClusterExtensionVersionRange(t *testing.T) { r := CatalogResolver{} pkgName := randPkg() - ce := buildFooClusterExtension(pkgName, []string{}, "foobar", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{}, "foobar", ocv1alpha1.UpgradeConstraintPolicyCatalogProvided) _, _, _, err := r.Resolve(context.Background(), ce, nil) assert.EqualError(t, err, `desired version range "foobar" is invalid: improper constraint: foobar`) } @@ -37,7 +37,7 @@ func TestErrorWalkingCatalogs(t *testing.T) { return fmt.Errorf("fake error") }} pkgName := randPkg() - ce := buildFooClusterExtension(pkgName, []string{}, "", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{}, "", ocv1alpha1.UpgradeConstraintPolicyCatalogProvided) _, _, _, err := r.Resolve(context.Background(), ce, nil) assert.EqualError(t, err, "error walking catalogs: fake error") } @@ -50,7 +50,7 @@ func TestErrorGettingPackage(t *testing.T) { } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} pkgName := randPkg() - ce := buildFooClusterExtension(pkgName, []string{}, "", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{}, "", ocv1alpha1.UpgradeConstraintPolicyCatalogProvided) _, _, _, err := r.Resolve(context.Background(), ce, nil) assert.EqualError(t, err, fmt.Sprintf(`error walking catalogs: error getting package %q from catalog "a": fake error`, pkgName)) } @@ -69,7 +69,7 @@ func TestPackageDoesNotExist(t *testing.T) { } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} pkgName := randPkg() - ce := buildFooClusterExtension(pkgName, []string{}, "", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{}, "", ocv1alpha1.UpgradeConstraintPolicyCatalogProvided) _, _, _, err := r.Resolve(context.Background(), ce, nil) assert.EqualError(t, err, fmt.Sprintf(`no bundles found for package %q`, pkgName)) } @@ -88,7 +88,7 @@ func TestPackageExists(t *testing.T) { }, } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} - ce := buildFooClusterExtension(pkgName, []string{}, "", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{}, "", ocv1alpha1.UpgradeConstraintPolicyCatalogProvided) gotBundle, gotVersion, gotDeprecation, err := r.Resolve(context.Background(), ce, nil) require.NoError(t, err) assert.Equal(t, genBundle(pkgName, "3.0.0"), *gotBundle) @@ -117,7 +117,7 @@ func TestValidationFailed(t *testing.T) { }, }, } - ce := buildFooClusterExtension(pkgName, []string{}, "", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{}, "", ocv1alpha1.UpgradeConstraintPolicyCatalogProvided) _, _, _, err := r.Resolve(context.Background(), ce, nil) require.Error(t, err) } @@ -136,7 +136,7 @@ func TestVersionDoesNotExist(t *testing.T) { }, } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} - ce := buildFooClusterExtension(pkgName, []string{}, "4.0.0", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{}, "4.0.0", ocv1alpha1.UpgradeConstraintPolicyCatalogProvided) _, _, _, err := r.Resolve(context.Background(), ce, nil) assert.EqualError(t, err, fmt.Sprintf(`no bundles found for package %q matching version "4.0.0"`, pkgName)) } @@ -155,7 +155,7 @@ func TestVersionExists(t *testing.T) { }, } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} - ce := buildFooClusterExtension(pkgName, []string{}, ">=1.0.0 <2.0.0", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{}, ">=1.0.0 <2.0.0", ocv1alpha1.UpgradeConstraintPolicyCatalogProvided) gotBundle, gotVersion, gotDeprecation, err := r.Resolve(context.Background(), ce, nil) require.NoError(t, err) assert.Equal(t, genBundle(pkgName, "1.0.2"), *gotBundle) @@ -177,7 +177,7 @@ func TestChannelDoesNotExist(t *testing.T) { }, } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} - ce := buildFooClusterExtension(pkgName, []string{"stable"}, "", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{"stable"}, "", ocv1alpha1.UpgradeConstraintPolicyCatalogProvided) _, _, _, err := r.Resolve(context.Background(), ce, nil) assert.EqualError(t, err, fmt.Sprintf(`no bundles found for package %q in channels [stable]`, pkgName)) } @@ -196,7 +196,7 @@ func TestChannelExists(t *testing.T) { }, } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} - ce := buildFooClusterExtension(pkgName, []string{"beta"}, "", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{"beta"}, "", ocv1alpha1.UpgradeConstraintPolicyCatalogProvided) gotBundle, gotVersion, gotDeprecation, err := r.Resolve(context.Background(), ce, nil) require.NoError(t, err) assert.Equal(t, genBundle(pkgName, "1.0.2"), *gotBundle) @@ -218,7 +218,7 @@ func TestChannelExistsButNotVersion(t *testing.T) { }, } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} - ce := buildFooClusterExtension(pkgName, []string{"beta"}, "3.0.0", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{"beta"}, "3.0.0", ocv1alpha1.UpgradeConstraintPolicyCatalogProvided) _, _, _, err := r.Resolve(context.Background(), ce, nil) assert.EqualError(t, err, fmt.Sprintf(`no bundles found for package %q matching version "3.0.0" in channels [beta]`, pkgName)) } @@ -237,7 +237,7 @@ func TestVersionExistsButNotChannel(t *testing.T) { }, } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} - ce := buildFooClusterExtension(pkgName, []string{"stable"}, "1.0.0", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{"stable"}, "1.0.0", ocv1alpha1.UpgradeConstraintPolicyCatalogProvided) _, _, _, err := r.Resolve(context.Background(), ce, nil) assert.EqualError(t, err, fmt.Sprintf(`no bundles found for package %q matching version "1.0.0" in channels [stable]`, pkgName)) } @@ -256,7 +256,7 @@ func TestChannelAndVersionExist(t *testing.T) { }, } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} - ce := buildFooClusterExtension(pkgName, []string{"alpha"}, "0.1.0", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{"alpha"}, "0.1.0", ocv1alpha1.UpgradeConstraintPolicyCatalogProvided) gotBundle, gotVersion, gotDeprecation, err := r.Resolve(context.Background(), ce, nil) require.NoError(t, err) assert.Equal(t, genBundle(pkgName, "0.1.0"), *gotBundle) @@ -278,7 +278,7 @@ func TestPreferNonDeprecated(t *testing.T) { }, } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} - ce := buildFooClusterExtension(pkgName, []string{}, ">=0.1.0 <=1.0.0", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{}, ">=0.1.0 <=1.0.0", ocv1alpha1.UpgradeConstraintPolicyCatalogProvided) gotBundle, gotVersion, gotDeprecation, err := r.Resolve(context.Background(), ce, nil) require.NoError(t, err) assert.Equal(t, genBundle(pkgName, "0.1.0"), *gotBundle) @@ -300,7 +300,7 @@ func TestAcceptDeprecated(t *testing.T) { }, } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} - ce := buildFooClusterExtension(pkgName, []string{}, ">=1.0.0 <=1.0.1", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{}, ">=1.0.0 <=1.0.1", ocv1alpha1.UpgradeConstraintPolicyCatalogProvided) gotBundle, gotVersion, gotDeprecation, err := r.Resolve(context.Background(), ce, nil) require.NoError(t, err) assert.Equal(t, genBundle(pkgName, "1.0.1"), *gotBundle) @@ -383,7 +383,7 @@ func TestPackageVariationsBetweenCatalogs(t *testing.T) { r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} t.Run("when bundle candidates for a package are deprecated in all but one catalog", func(t *testing.T) { - ce := buildFooClusterExtension(pkgName, []string{}, ">=1.0.0 <=1.0.3", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{}, ">=1.0.0 <=1.0.3", ocv1alpha1.UpgradeConstraintPolicyCatalogProvided) gotBundle, gotVersion, gotDeprecation, err := r.Resolve(context.Background(), ce, nil) require.NoError(t, err) // We choose the only non-deprecated package @@ -393,7 +393,7 @@ func TestPackageVariationsBetweenCatalogs(t *testing.T) { }) t.Run("when bundle candidates are found and deprecated in multiple catalogs", func(t *testing.T) { - ce := buildFooClusterExtension(pkgName, []string{}, ">=1.0.0 <=1.0.1", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{}, ">=1.0.0 <=1.0.1", ocv1alpha1.UpgradeConstraintPolicyCatalogProvided) gotBundle, gotVersion, gotDeprecation, err := r.Resolve(context.Background(), ce, nil) require.Error(t, err) // We will not make a decision on which catalog to use @@ -404,7 +404,7 @@ func TestPackageVariationsBetweenCatalogs(t *testing.T) { }) t.Run("when bundle candidates are found and not deprecated in multiple catalogs", func(t *testing.T) { - ce := buildFooClusterExtension(pkgName, []string{}, ">=1.0.0 <=1.0.4", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{}, ">=1.0.0 <=1.0.4", ocv1alpha1.UpgradeConstraintPolicyCatalogProvided) gotBundle, gotVersion, gotDeprecation, err := r.Resolve(context.Background(), ce, nil) require.Error(t, err) // We will not make a decision on which catalog to use @@ -415,7 +415,7 @@ func TestPackageVariationsBetweenCatalogs(t *testing.T) { }) t.Run("highest semver bundle is chosen when candidates are all from the same catalog", func(t *testing.T) { - ce := buildFooClusterExtension(pkgName, []string{}, ">=1.0.4 <=1.0.5", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{}, ">=1.0.4 <=1.0.5", ocv1alpha1.UpgradeConstraintPolicyCatalogProvided) gotBundle, gotVersion, gotDeprecation, err := r.Resolve(context.Background(), ce, nil) require.NoError(t, err) // Bundles within one catalog for a package will be sorted by semver and deprecation and the best is returned @@ -440,7 +440,7 @@ func TestUpgradeFoundLegacy(t *testing.T) { }, } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} - ce := buildFooClusterExtension(pkgName, []string{}, "", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{}, "", ocv1alpha1.UpgradeConstraintPolicyCatalogProvided) installedBundle := &ocv1alpha1.BundleMetadata{ Name: bundleName(pkgName, "0.1.0"), Version: "0.1.0", @@ -468,7 +468,7 @@ func TestUpgradeNotFoundLegacy(t *testing.T) { }, } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} - ce := buildFooClusterExtension(pkgName, []string{}, "<1.0.0 >=2.0.0", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{}, "<1.0.0 >=2.0.0", ocv1alpha1.UpgradeConstraintPolicyCatalogProvided) installedBundle := &ocv1alpha1.BundleMetadata{ Name: bundleName(pkgName, "0.1.0"), Version: "0.1.0", @@ -493,7 +493,7 @@ func TestUpgradeFoundSemver(t *testing.T) { }, } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} - ce := buildFooClusterExtension(pkgName, []string{}, "", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{}, "", ocv1alpha1.UpgradeConstraintPolicyCatalogProvided) installedBundle := &ocv1alpha1.BundleMetadata{ Name: bundleName(pkgName, "1.0.0"), Version: "1.0.0", @@ -523,7 +523,7 @@ func TestUpgradeNotFoundSemver(t *testing.T) { }, } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} - ce := buildFooClusterExtension(pkgName, []string{}, "!=0.1.0", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{}, "!=0.1.0", ocv1alpha1.UpgradeConstraintPolicyCatalogProvided) installedBundle := &ocv1alpha1.BundleMetadata{ Name: bundleName(pkgName, "0.1.0"), Version: "0.1.0", @@ -548,7 +548,7 @@ func TestDowngradeFound(t *testing.T) { }, } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} - ce := buildFooClusterExtension(pkgName, []string{}, "<1.0.2", ocv1alpha1.UpgradeConstraintPolicyIgnore) + ce := buildFooClusterExtension(pkgName, []string{}, "<1.0.2", ocv1alpha1.UpgradeConstraintPolicySelfCertified) installedBundle := &ocv1alpha1.BundleMetadata{ Name: bundleName(pkgName, "1.0.2"), Version: "1.0.2", @@ -576,7 +576,7 @@ func TestDowngradeNotFound(t *testing.T) { }, } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} - ce := buildFooClusterExtension(pkgName, []string{}, ">0.1.0 <1.0.0", ocv1alpha1.UpgradeConstraintPolicyIgnore) + ce := buildFooClusterExtension(pkgName, []string{}, ">0.1.0 <1.0.0", ocv1alpha1.UpgradeConstraintPolicySelfCertified) installedBundle := &ocv1alpha1.BundleMetadata{ Name: bundleName(pkgName, "1.0.2"), Version: "1.0.2", @@ -673,7 +673,7 @@ func (w staticCatalogWalker) WalkCatalogs(ctx context.Context, _ string, f Catal ObjectMeta: metav1.ObjectMeta{ Name: k, Labels: map[string]string{ - "olm.operatorframework.io/metadata.name": k, + "olm.operatorframework.io/name": k, }, }, } @@ -851,8 +851,8 @@ func TestClusterExtensionMatchLabel(t *testing.T) { }, } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} - ce := buildFooClusterExtension(pkgName, []string{}, "", ocv1alpha1.UpgradeConstraintPolicyEnforce) - ce.Spec.Source.Catalog.Selector.MatchLabels = map[string]string{"olm.operatorframework.io/metadata.name": "b"} + ce := buildFooClusterExtension(pkgName, []string{}, "", ocv1alpha1.UpgradeConstraintPolicyCatalogProvided) + ce.Spec.Source.Catalog.Selector.MatchLabels = map[string]string{"olm.operatorframework.io/name": "b"} _, _, _, err := r.Resolve(context.Background(), ce, nil) require.NoError(t, err) @@ -870,8 +870,8 @@ func TestClusterExtensionNoMatchLabel(t *testing.T) { }, } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} - ce := buildFooClusterExtension(pkgName, []string{}, "", ocv1alpha1.UpgradeConstraintPolicyEnforce) - ce.Spec.Source.Catalog.Selector.MatchLabels = map[string]string{"olm.operatorframework.io/metadata.name": "a"} + ce := buildFooClusterExtension(pkgName, []string{}, "", ocv1alpha1.UpgradeConstraintPolicyCatalogProvided) + ce.Spec.Source.Catalog.Selector.MatchLabels = map[string]string{"olm.operatorframework.io/name": "a"} _, _, _, err := r.Resolve(context.Background(), ce, nil) require.Error(t, err) @@ -912,7 +912,7 @@ func TestUnequalPriority(t *testing.T) { } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} - ce := buildFooClusterExtension(pkgName, []string{}, "", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{}, "", ocv1alpha1.UpgradeConstraintPolicyCatalogProvided) _, gotVersion, _, err := r.Resolve(context.Background(), ce, nil) require.NoError(t, err) require.Equal(t, bsemver.MustParse("1.0.0"), *gotVersion) @@ -933,7 +933,7 @@ func TestMultiplePriority(t *testing.T) { } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} - ce := buildFooClusterExtension(pkgName, []string{}, ">=1.0.0 <=1.0.1", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{}, ">=1.0.0 <=1.0.1", ocv1alpha1.UpgradeConstraintPolicyCatalogProvided) gotBundle, gotVersion, gotDeprecation, err := r.Resolve(context.Background(), ce, nil) require.Error(t, err) assert.ErrorContains(t, err, "in multiple catalogs with the same priority [a b c]") @@ -956,7 +956,7 @@ func TestMultipleChannels(t *testing.T) { }, } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} - ce := buildFooClusterExtension(pkgName, []string{"beta", "alpha"}, "", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{"beta", "alpha"}, "", ocv1alpha1.UpgradeConstraintPolicyCatalogProvided) gotBundle, gotVersion, gotDeprecation, err := r.Resolve(context.Background(), ce, nil) require.NoError(t, err) assert.Equal(t, genBundle(pkgName, "2.0.0"), *gotBundle) diff --git a/test/e2e/cluster_extension_install_test.go b/test/e2e/cluster_extension_install_test.go index 61412bbd6..f1b03e3f2 100644 --- a/test/e2e/cluster_extension_install_test.go +++ b/test/e2e/cluster_extension_install_test.go @@ -446,7 +446,7 @@ func TestClusterExtensionForceInstallNonSuccessorVersion(t *testing.T) { t.Log("By updating the ClusterExtension resource to a non-successor version") // 1.2.0 does not replace/skip/skipRange 1.0.0. clusterExtension.Spec.Source.Catalog.Version = "1.2.0" - clusterExtension.Spec.Source.Catalog.UpgradeConstraintPolicy = ocv1alpha1.UpgradeConstraintPolicyIgnore + clusterExtension.Spec.Source.Catalog.UpgradeConstraintPolicy = ocv1alpha1.UpgradeConstraintPolicySelfCertified require.NoError(t, c.Update(context.Background(), clusterExtension)) t.Log("By eventually reporting a satisfiable resolution") require.EventuallyWithT(t, func(ct *assert.CollectT) { From 8f9b615f78718b8070101e670831a002d9f7b40f Mon Sep 17 00:00:00 2001 From: Sid Kattoju <83437591+skattoju@users.noreply.github.com> Date: Wed, 11 Sep 2024 09:03:20 -0400 Subject: [PATCH 2/2] change match labels to olm.operatorframework.io/metadata.name fix unintentional override due to error in rebase Co-authored-by: Joe Lanford --- internal/resolve/catalog_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/resolve/catalog_test.go b/internal/resolve/catalog_test.go index 8746fc62d..17d0007bc 100644 --- a/internal/resolve/catalog_test.go +++ b/internal/resolve/catalog_test.go @@ -673,7 +673,7 @@ func (w staticCatalogWalker) WalkCatalogs(ctx context.Context, _ string, f Catal ObjectMeta: metav1.ObjectMeta{ Name: k, Labels: map[string]string{ - "olm.operatorframework.io/name": k, + "olm.operatorframework.io/metadata.name": k, }, }, } @@ -852,7 +852,7 @@ func TestClusterExtensionMatchLabel(t *testing.T) { } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} ce := buildFooClusterExtension(pkgName, []string{}, "", ocv1alpha1.UpgradeConstraintPolicyCatalogProvided) - ce.Spec.Source.Catalog.Selector.MatchLabels = map[string]string{"olm.operatorframework.io/name": "b"} + ce.Spec.Source.Catalog.Selector.MatchLabels = map[string]string{"olm.operatorframework.io/metadata.name": "b"} _, _, _, err := r.Resolve(context.Background(), ce, nil) require.NoError(t, err) @@ -871,7 +871,7 @@ func TestClusterExtensionNoMatchLabel(t *testing.T) { } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} ce := buildFooClusterExtension(pkgName, []string{}, "", ocv1alpha1.UpgradeConstraintPolicyCatalogProvided) - ce.Spec.Source.Catalog.Selector.MatchLabels = map[string]string{"olm.operatorframework.io/name": "a"} + ce.Spec.Source.Catalog.Selector.MatchLabels = map[string]string{"olm.operatorframework.io/metadata.name": "a"} _, _, _, err := r.Resolve(context.Background(), ce, nil) require.Error(t, err)