-
Notifications
You must be signed in to change notification settings - Fork 282
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
util/version: pre-release tags are not taken in to consideration in ShouldUpgrade() #63
Comments
I think this problem also applies to all versions with metadata such release candidates (rc). Sometimes (might be quite often) you might not want to update to release candidate your production workloads. We need a bit more generic solution that would still be easy to use and useful. How about new label that would have something like Or it could be inverted, where you have to specify something to allow metadata in versions. |
You are correct, it applies to any SemVer tag formatted like so: I like your idea of having something that's simple to use, and that label seems like it would handle most cases. I'm not sure I'm a huge fan of I think this solution would solve most deployment use cases, but for one of the use cases I had in mind with keel this solution wouldn't work for us. I can see situations, in keel, where I'd want the policy to be
Eventually I may want to relax the restrictions and have I was running out of energy when I opened this issue last night, and wasn't able to include a more concrete example of what I was thinking: func stringToPolicyType(p string) types.PolicyType {
// imagine this would take "minor" and return `types.PolicyTypeMinor`
}
func stringToPreReleasePolicy(p string) types.PolicyType {
// imagine this would take "patch" and return `types.PolicyTypePreReleasePatch`
}
// assume cfg["policy"] lines up with the current policy setting,
// and that cfg["prerelease"] lines up with the pre-release values (same values as policy)
// cfg["policy"] = minor; cfg["prerelease"] = patch
// bit-wise AND to combine both conditions in to one integer
policy := stringToPolicyType(cfg["policy"]) & stringToPreReleasePolicy(cfg["prerelease"])
// we can then do bit-wise math to calculate the desired behaviors
// if our policy is a minor policy..
if policy&types.PolicyTypeMinor == types.PolicyTypeMinor {
// if this is a preRelease minor release, and our policy allows us to do minor pre-releases
// Note: because of the policy we defined above,
// the second half of this expression should evaluate to false
if isPreRelease(newVersion) && policy&types.PolicyTypePreReleaseMinor == types.PolicyTypePreReleaseMinor {
// do the thing
}
} |
Let's get back to this example with
Could we just make this default behaviour?
Default behaviour - only allow This would allow to safely upgrade to new versions. Policy I think this would work for your use case. |
In your first example, what if I want to test the It's quite possible I'm not understanding what's being proposed, so let me try to make sure I understand. We'd have a flag that turns on support for managing pre-releases, and using that keel would make assumptions about how you want pre-release tags handled based on the policy you have selected.
|
Hey there ! I'm reviving this with another idea: I believe everything needs to stay the same in the keel.sh configs. |
I agree, I think that metadata is stored in either those fields (can't remember which one) https://github.com/keel-hq/keel/blob/master/types/types.go#L76-L77. It could be checked by k8s and helm providers. Need to check but maybe the only change has to be made in this function https://github.com/keel-hq/keel/blob/master/util/version/version.go#L119:6 . |
Trying something right now then 😄 |
So that was quick, |
In my organization we're working on using SemVer for all of our releases, with the use of pre-release tags to test experimental builds. For pre-release builds, we increment the patch and then add the pre-release information at the end. So if
v1.2.2
is the last tag, the pre-release would bev1.2.3-preNNNNNN
.The problem is that
keel
does not currently inspect the information about the PreRelease to understand whether it's a "proper release"[1]. This means that if you have your policy set topatch
, a pre-release of the next patch version will be deployed. To give a quick overview with each policy type there is a different combination of pre-release tags which someone may want to deploy:v1.2.2
=>v1.2.3-pre
v1.2.3
=>v1.3.0-pre
v1.2.3
=>v2.0.0-pre
v1.2.3-pre
=>v1.3.0-pre
v1.2.3-pre
=>v1.3.0
Attached to the bottom of this issue is a patch with a unit test showing the failure mode that made me realize this was a potential issue. [2]
To solving the problem, it seems there are two ways to solve this problem within keel:
PolicyTypePatchPreRelease
,PolicyTypeMinorPreRelease
, etc.) and do the additional checksprelreasePolicy
value that can contain the same values aspolicy
does now (and maybe renamepolicy
toreleasePolicy
). We could then have a matrix of behaviors based on the releasePolicy and the prereleasePolicy.The second approach feels like the most powerful, and could allow you to do something like have a
releasePolicy: minor
so you get all of the minor + patch updates, but aprereleasePolicy: patch
so that you only run experimental patch builds. This might be useful for something like a QA environment.I think one of the easier ways to tackle this, since it's already a numerical value, to use it as bitwise flags. Policies could then be created by doing something like
types.PolicyTypePreReleasePatch & types.PolicyTypeMinor
. I'd be happy to take on implementing it once a good design is figured out.[1] I quote proper release, because this could be up to who you ask.
[2]
The text was updated successfully, but these errors were encountered: