-
Notifications
You must be signed in to change notification settings - Fork 72
✨ Add ReleaseVersionPriority feature gate for re-release upgrade support #2543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
7a8ab66
885f015
6157202
8dcab49
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -10,6 +10,7 @@ import ( | |||
| "github.com/operator-framework/operator-registry/alpha/declcfg" | ||||
| "github.com/operator-framework/operator-registry/alpha/property" | ||||
|
|
||||
| "github.com/operator-framework/operator-controller/internal/operator-controller/bundle" | ||||
| "github.com/operator-framework/operator-controller/internal/operator-controller/catalogmetadata/compare" | ||||
| "github.com/operator-framework/operator-controller/internal/operator-controller/catalogmetadata/filter" | ||||
| ) | ||||
|
|
@@ -68,3 +69,88 @@ func TestInAnyChannel(t *testing.T) { | |||
| assert.False(t, fStable(b2)) | ||||
| assert.False(t, fStable(b3)) | ||||
| } | ||||
|
|
||||
| func TestSameVersionHigherRelease(t *testing.T) { | ||||
| const testPackageName = "test-package" | ||||
|
|
||||
| // Expected bundle version 2.0.0+1 | ||||
| expect, err := bundle.NewLegacyRegistryV1VersionRelease("2.0.0+1") | ||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd suggest putting the Also related: do we need to add code that knows how to parse the new
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. iirc, @grokspawn's design called for a specific precedence when handling both |
||||
| require.NoError(t, err) | ||||
|
|
||||
| tests := []struct { | ||||
| name string | ||||
| bundleVersion string | ||||
| shouldMatch bool | ||||
| }{ | ||||
| { | ||||
| name: "same version, higher release", | ||||
| bundleVersion: "2.0.0+2", | ||||
| shouldMatch: true, | ||||
| }, | ||||
| { | ||||
| name: "same version, same release", | ||||
| bundleVersion: "2.0.0+1", | ||||
| shouldMatch: false, | ||||
| }, | ||||
| { | ||||
| name: "same version, lower release", | ||||
| bundleVersion: "2.0.0+0", | ||||
| shouldMatch: false, | ||||
| }, | ||||
| { | ||||
| name: "same version, no release", | ||||
| bundleVersion: "2.0.0", | ||||
| shouldMatch: false, | ||||
| }, | ||||
| { | ||||
| name: "different version, higher release", | ||||
| bundleVersion: "2.1.0+2", | ||||
| shouldMatch: false, | ||||
| }, | ||||
| } | ||||
|
|
||||
| for _, tt := range tests { | ||||
| t.Run(tt.name, func(t *testing.T) { | ||||
| testBundle := declcfg.Bundle{ | ||||
| Name: "test-package.v" + tt.bundleVersion, | ||||
| Package: testPackageName, | ||||
| Properties: []property.Property{ | ||||
| property.MustBuildPackage(testPackageName, tt.bundleVersion), | ||||
| }, | ||||
| } | ||||
|
|
||||
| f := filter.SameVersionHigherRelease(*expect) | ||||
| assert.Equal(t, tt.shouldMatch, f(testBundle), "version %s should match=%v", tt.bundleVersion, tt.shouldMatch) | ||||
| }) | ||||
| } | ||||
|
|
||||
| // Test when expected version has no release (e.g: "2.0.0") | ||||
| t.Run("expected version without release", func(t *testing.T) { | ||||
| expectNoRelease, err := bundle.NewLegacyRegistryV1VersionRelease("2.0.0") | ||||
| require.NoError(t, err) | ||||
|
|
||||
| // Bundle with release should be considered higher | ||||
| bundleWithRelease := declcfg.Bundle{ | ||||
| Name: "test-package.v2.0.0+1", | ||||
| Package: testPackageName, | ||||
| Properties: []property.Property{ | ||||
| property.MustBuildPackage(testPackageName, "2.0.0+1"), | ||||
| }, | ||||
| } | ||||
|
|
||||
| f := filter.SameVersionHigherRelease(*expectNoRelease) | ||||
| assert.True(t, f(bundleWithRelease), "2.0.0+1 should be higher than 2.0.0") | ||||
| }) | ||||
|
|
||||
| // Test error case: invalid bundle (no package property) | ||||
| t.Run("invalid bundle - no package property", func(t *testing.T) { | ||||
| testBundle := declcfg.Bundle{ | ||||
| Name: "test-package.invalid", | ||||
| Package: testPackageName, | ||||
| Properties: []property.Property{}, | ||||
| } | ||||
|
|
||||
| f := filter.SameVersionHigherRelease(*expect) | ||||
| assert.False(t, f(testBundle)) | ||||
| }) | ||||
| } | ||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ import ( | |
|
|
||
| ocv1 "github.com/operator-framework/operator-controller/api/v1" | ||
| "github.com/operator-framework/operator-controller/internal/operator-controller/bundle" | ||
| "github.com/operator-framework/operator-controller/internal/operator-controller/features" | ||
| "github.com/operator-framework/operator-controller/internal/shared/util/filter" | ||
| ) | ||
|
|
||
|
|
@@ -28,11 +29,22 @@ func SuccessorsOf(installedBundle ocv1.BundleMetadata, channels ...declcfg.Chann | |
| return nil, fmt.Errorf("getting successorsPredicate: %w", err) | ||
| } | ||
|
|
||
| // We need either successors or current version (no upgrade) | ||
| return filter.Or( | ||
| // Build the final predicate based on feature gate status | ||
| predicates := []filter.Predicate[declcfg.Bundle]{ | ||
| successorsPredicate, | ||
| ExactVersionRelease(*installedVersionRelease), | ||
| ), nil | ||
| } | ||
|
|
||
| // If release version priority is enabled, also consider bundles | ||
| // with the same semantic version but higher release as valid successors. | ||
| // This allows upgrades to re-released bundles (e.g., 2.0.0+1 -> 2.0.0+2). | ||
|
Comment on lines
+38
to
+40
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if the re-release version is already in the explicit upgrade graph? In that case, should we ignore it and let its explicit channel entry take precedence? That would preserve existing behavior. |
||
| if features.OperatorControllerFeatureGate.Enabled(features.ReleaseVersionPriority) { | ||
| predicates = append(predicates, SameVersionHigherRelease(*installedVersionRelease)) | ||
| } | ||
rashmigottipati marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // Bundle matches if it's a channel successor, current version (no upgrade), | ||
| // or (when feature gate enabled) same version with higher release | ||
| return filter.Or(predicates...), nil | ||
| } | ||
|
|
||
| func legacySuccessor(installedBundle ocv1.BundleMetadata, channels ...declcfg.Channel) (filter.Predicate[declcfg.Bundle], error) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could failing silently here lead to some hard to spot bugs?