-
Notifications
You must be signed in to change notification settings - Fork 298
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
Windows: Don't abort everything if $HOME
is not writable
#8042
Windows: Don't abort everything if $HOME
is not writable
#8042
Conversation
If we couldn't find a correct path for kubeconfig (e.g. because the home directory is not writable), log an error instead of throwing, as the latter breaks startup. Signed-off-by: Mark Yen <mark.yen@suse.com>
This makes the Windows integration report errors as diagnostics. The messages aren't quite detailed enough yet, but it's enough to let the user know there is a problem. Signed-off-by: Mark Yen <mark.yen@suse.com>
* Helper function to trigger a diagnostic report. If a diagnostic should be | ||
* cleared, call this with the error unset. | ||
*/ | ||
protected diagnostic(input: {key: DiagnosticKey, distro?: string, error?: unknown}) { |
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 you think this needs a check for the input key? e.g.
if (!input.key) {
throw new Error('Diagnostic key is required');
}
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, because key
is not optional (distro
and error
are), per TypeScript annotations. Also, this is a protected
method, so we should be able to expect the callers to be type-checked.
config = JSON.parse(await fs.promises.readFile(configPath, 'utf-8')); | ||
} catch (error) { | ||
if (error && typeof error === 'object' && 'code' in error && error.code === 'ENOENT') { | ||
// If the file does not exist, create it. |
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.
Are we supposed to create a file here?
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.
We do on line 472. (This is just the old code with an extra layer of indenting.)
applicable() { | ||
return Promise.resolve(process.platform === 'win32'); | ||
}, | ||
check(): Promise<DiagnosticsCheckerSingleResult[]> { |
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.
It's a little hard to see what's happening here should it be broken down to:
const mapResults = (results: Record<string, DiagnosticsCheckerResult>) => {
return Object.entries(results).map(([id, result]) => ({ ...result, id }));
};
check(): Promise<DiagnosticsCheckerSingleResult[]> {
return Promise.resolve(mapResults(cachedResults));
}
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.
Fixed in 6e1d40a (I factored out the inner map function instead, and Nino seems okay with that).
https://github.com/rancher-sandbox/rancher-desktop/pull/8042/files#r1906116013 Signed-off-by: Mark Yen <mark.yen@suse.com>
This fixes Windows such that if we fail to create
~/.kube
we don't fall over immediately and end up hanging indefinitely waiting for Kubernetes. Instead, we can proceed until the correct step and correctly throw up an error when we attempt to update thekubeconfig
.This also contains the start of reporting Windows integration errors as diagnostics, so that users can take action easier.
This is related to #7824 but does not fix it (because we still fail to write the
kubeconfig
).