-
Notifications
You must be signed in to change notification settings - Fork 277
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 k8s versions at startup #5199
Conversation
// If we're here either there's no existing cfg.k8s.version, or it isn't valid | ||
if (!availableVersions.length) { | ||
if (currentConfigVersionString) { | ||
console.log(invalidK8sVersionMainMessage); | ||
} else { | ||
console.log('Internal error: no available kubernetes versions found.'); | ||
} | ||
throw new Error('No kubernetes version available.'); | ||
} |
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.
Do we want to move the check for availableVersions
to the beginning of this function? It looks to me like we can't do anything without a collection of avaialableVersions
so we'd be able to handle the error case without having to go through the above block first.
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.
good point. Let's me break two if blocks into one.
This also traps `InvalidVersion` errors when the k8s.version field is invalid or empty. Hard to find because it came out of an `Array.find()` callback method. Invalid versions are logged to kube.log but aren't treated as fatal errors. Signed-off-by: Eric Promislow <epromislow@suse.com>
Signed-off-by: Eric Promislow <epromislow@suse.com>
Signed-off-by: Eric Promislow <epromislow@suse.com>
Signed-off-by: Eric Promislow <epromislow@suse.com>
Signed-off-by: Eric Promislow <epromislow@suse.com>
Keep logging if no-modal-dialogs is specified. Signed-off-by: Eric Promislow <epromislow@suse.com>
Signed-off-by: Eric Promislow <epromislow@suse.com>
b323b91
to
37eb237
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.
Looks good!
Fixes #4952
First, the invalid version can come from a deployment profile, the command-line, or be manually written into an existing settings file. All of them are handled the same way.
Currently we quietly change an invalid version to the default k8s version, usually the most recent stable version.
The first change here is to log this change to
kube.log
. Also this code was made shared between lima and wsl, so this should all work on Windows.The second change is to prevent mysterious
TypeError: Invalid version
messages from propagating to a UI dialog box. This was caused byavailableVersions.find(v => v.compare(version) === 0)
. Ifversion
is null, this will throw an uncaughtTypeError
exception.The third change is to add a bats test to verify this works.