-
Notifications
You must be signed in to change notification settings - Fork 702
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
Add defaultIncludePrereleases
#4165
Add defaultIncludePrereleases
#4165
Conversation
Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>
createdPkgInstall, err := s.getPkgInstall(context.Background(), "default", tc.request.TargetContext.Namespace, createInstalledPackageResponse.InstalledPackageRef.Identifier) | ||
if err != nil { | ||
t.Fatalf("%+v", err) | ||
} | ||
|
||
if got, want := createdPkgInstall, tc.expectedPackageInstall; !cmp.Equal(want, got, ignoreUnexported) { | ||
t.Errorf("mismatch (-want +got):\n%s", cmp.Diff(want, got, ignoreUnexported)) |
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.
Missing assert added in this PR
PackageRef: &packagingv1alpha1.PackageRef{ | ||
RefName: "tetris.foo.example.com", | ||
VersionSelection: &vendirversions.VersionSelectionSemver{ | ||
Constraints: ">=1.0.0 <1.1.0", |
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.
Added test cases for the constraints when passing a defaultUpgradePolicy
@@ -2885,110 +2891,58 @@ func TestCreateInstalledPackage(t *testing.T) { | |||
PackageRef: &packagingv1alpha1.PackageRef{ | |||
RefName: "tetris.foo.example.com", | |||
VersionSelection: &vendirversions.VersionSelectionSemver{ | |||
Constraints: "1.2.3", | |||
Constraints: "1.0.0", | |||
Prereleases: &vendirversions.VersionSelectionSemverPrereleases{}, |
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.
Test case enabling the defaultIncludePrereleases
Key: "values.yaml", | ||
}, | ||
}, | ||
}, | ||
Paused: false, | ||
Canceled: false, | ||
SyncPeriod: &metav1.Duration{(time.Second * 30)}, | ||
SyncPeriod: nil, | ||
NoopDelete: false, | ||
}, | ||
Status: packagingv1alpha1.PackageInstallStatus{ | ||
GenericStatus: kappctrlv1alpha1.GenericStatus{ | ||
ObservedGeneration: 1, | ||
Conditions: []kappctrlv1alpha1.AppCondition{{ | ||
Type: kappctrlv1alpha1.ReconcileSucceeded, | ||
Status: k8scorev1.ConditionTrue, | ||
Reason: "baz", | ||
Message: "qux", | ||
}}, | ||
FriendlyDescription: "foo", | ||
UsefulErrorMessage: "Deployed", | ||
ObservedGeneration: 0, | ||
Conditions: nil, | ||
FriendlyDescription: "", | ||
UsefulErrorMessage: "", | ||
}, | ||
Version: "1.2.3", | ||
LastAttemptedVersion: "1.2.3", | ||
Version: "", | ||
LastAttemptedVersion: "", |
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.
Minor changes in the test cases to match the actual PackageInstall
being created.
kappControllerPluginParsedConfig struct { | ||
defaultUpgradePolicy upgradePolicy | ||
defaultIncludePrereleases bool |
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.
Struct holding the plugin's config.
|
||
// parse the configuration options | ||
defaultUpgradePolicy := upgradePolicyMapping[pluginConfig.KappController.Packages.V1alpha1.DefaultUpgradePolicy] | ||
defaultIncludePrereleases, err := strconv.ParseBool(pluginConfig.KappController.Packages.V1alpha1.DefaultUpgradePolicy) |
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.
Is pluginConfig.KappController.Packages.V1alpha1.DefaultUpgradePolicy
the right param to parse for defaultIncludePrereleases
?
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.
Absolutely right! I didn't notice, thanks!
Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>
chart/kubeapps/values.yaml
Outdated
@@ -1638,6 +1638,8 @@ kubeappsapis: | |||
## @param kubeappsapis.pluginConfig.kappController.packages.v1alpha1.defaultUpgradePolicy Default upgrade policy generating version constraints | |||
## enum: [ "major", "minor", "patch", "none" ] | |||
defaultUpgradePolicy: none | |||
## @param kubeappsapis.pluginConfig.kappController.packages.v1alpha1.defaultIncludePrereleases Default policy for allowing pre-releases to be installed | |||
defaultIncludePrereleases: false |
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.
Sorry, just a thought: I know I'd suggested a boolean when reviewing your other PR - but it might be just as simple to actually have a value here (ie. rename defaultPrereleasesVersionSelection
that is empty (nil) by default, but can be set to {}
or whatever? This way, we don't have to later change this config option to support actually setting version selections for pre releases? I'm not suggesting we implement support for them yet, it'd still effectively be a boolean option for now, but one that doesn't need to change later.
Fine either way.
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.
No, it's fine. In fact, after re-reading the carvel issues and docs I've started having some doubts/questions, so I asked them at: https://kubernetes.slack.com/archives/CH8KCCKA5/p1643376802571959
In short, prereleases
can have three values:
prereleases: {}
: allow any prerelease if the version constraint allows it.prereleases: nil
: disallow any prerelease- Exception: if the version constraint is a prerelease itself:
1. Current behavior: error, it won't install a prerelease ifprereleases: nil
:
2. Future behavior: install it, it won't be required to setprereleases: {}
if the version constraint is a prerelease
- Exception: if the version constraint is a prerelease itself:
prereleases: {Identifiers: []string{"rc"}}
: allow only prerelease with "rc" as part of the name if the version constraint allows it.
I'm not suggesting we implement support for them yet, it'd still effectively be a boolean option for now, but one that doesn't need to change later.
It is mostly the same effort, I mean, it is just a matter of appending strings or not. I'll update this PR with the full implementation soon (edit: done). Thanks for the suggestion, much better this way!
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.
Also, I'd like to add (in a separate PR) another default config like allowDowngrading
or sth, to add the packaging.carvel.dev/downgradable: "
annotation to the PackageInstall objs to allow them to be downgraded: https://carvel.dev/kapp-controller/docs/latest/package-consumer-concepts/#downgrading
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.
Nice, yes, that'd be useful (as a kubeapps config default).
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.
Done: #4192 :)
Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>
Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com> Conflicts: cmd/kubeapps-apis/plugins/kapp_controller/packages/v1alpha1/server_data_adapters.go cmd/kubeapps-apis/plugins/kapp_controller/packages/v1alpha1/server_test.go
Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>
Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com> Conflicts: cmd/kubeapps-apis/plugins/kapp_controller/packages/v1alpha1/server.go cmd/kubeapps-apis/plugins/kapp_controller/packages/v1alpha1/server_test.go
Description of the change
Having considered #4085 (comment), the purpose of this PR is twofold:
defaultIncludePrereleases
param in the plugin-specific config to decide whether or not we should add theVersionSelectionSemverPrereleases{}
when creating the installed pkg.InstalledPackage
being created in a test case, so this PR also includes some minor changes in the test caseBenefits
Until we have a way to configure some options from the UI, this PR introduces a way to configure some plugin-specific options, specifically
defaultIncludePrereleases
for allowing installing pre-releases by kapp-controller.Possible drawbacks
N/A
Applicable issues
Additional information
N/A