-
Notifications
You must be signed in to change notification settings - Fork 308
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
Handle invalid locked k8s version field #5205
Conversation
b323b91
to
37eb237
Compare
ce28d28
to
80ac720
Compare
8c03609
to
e7c0e06
Compare
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.
LGTM. Tested in Linux and was alerted that the version in my locked file was invalid and that the most recent stable version of 1.27.3 would be used instead.
e7c0e06
to
073d22c
Compare
3a49e75
to
480ed95
Compare
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.
The logic looks fine to me, but is it possible to check the behaviour with BATS or e2e tests, so we don't break it in the future when we refactor stuff?
480ed95
to
3a3d8b8
Compare
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.
This PR really needs to include a BATS test that verifies all the situations it is supposed to cover.
3a3d8b8
to
5f9e67d
Compare
Actually writing the BATs test uncovered a case where an invalid locked k8s version was quietly changed to a valid one, so good show. And then I realized we need a BATs test where a specified valid k8s version on the command-line != the locked k8s version. |
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.
Thanks for adding the test!
I did a quick review of the new BATS test, just based on how the helper functions work. I haven't verified yet that the test covers all the acceptance criteria; will do that tomorrow.
ca37357
to
f56df81
Compare
618958f
to
4695b4d
Compare
4695b4d
to
818cbda
Compare
Signed-off-by: Eric Promislow <[email protected]>
…ock profile. Also add a BATs to verify this is implemented. Signed-off-by: Eric Promislow <[email protected]>
…valid locked one. Signed-off-by: Eric Promislow <[email protected]>
- Don't write tests that rely on marshalled exception objects in the log files. Rely on handcrafted messages. Signed-off-by: Eric Promislow <[email protected]>
966ba1e
to
726884b
Compare
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.
This looks fine to me now, but I would like @rak-phillip to review the TypeScript code one more time before we merge this!
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.
I think these changes look good, I just have one minor comment to address and then I think we're good to merge.
let storedVersion: semver.SemVer|null; | ||
let matchedVersion: semver.SemVer|undefined; | ||
const invalidK8sVersionMainMessage = `Requested kubernetes version '${ currentConfigVersionString }' is not a valid version.`; | ||
const sv = new SettingsValidator(); | ||
const lockedSettings = settingsImpl.getLockedSettings(); | ||
const versionIsLocked = lockedSettings.kubernetes?.version ?? 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.
Would we want to convert lockedSettings.kubernetes.version
to its boolean representation via something like const versionIsLocked = !!lockedSettings.kubernetes?.version ?? false;
? I know that truthy and falsy values are entirely valid, but doing the conversion more explicitly communicates what we are planning to do with this value later on.
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.
That isn't necessary. While the type of lockedSettings
is Record<string, any>
, it's like that because I still never get recursive typescript types right -- it should be
type LockedSettingsType = Record<string, boolean | LockedSettingsType>
So all references are either boolean or null (the expression isn't represented in the current object), and the expression as above is always boolean without needing a !!
.
Fixes #5203
More checks that any specified k8s field is valid, and doesn't conflict with the locked field, if given.
And also verify that if the k8s version field is locked, that it's also valid.
Waiting on PR 5199