-
Notifications
You must be signed in to change notification settings - Fork 284
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix fallback when no Kubernetes versions are available
If Rancher Desktop was previously started with a version, but the user wipes the `k3s-versions.json` cache and we fail to download a new copy, handle the error and disable Kubernetes instead of throwing an error. To make sure the user is aware of the issue, also pop a diagnostic to describe the situation. Signed-off-by: Mark Yen <mark.yen@suse.com>
- Loading branch information
Showing
8 changed files
with
103 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
pkg/rancher-desktop/main/diagnostics/kubeVersionsAvailable.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import mainEvents from '../mainEvents'; | ||
import { DiagnosticsCategory, DiagnosticsChecker, DiagnosticsCheckerResult } from './types'; | ||
|
||
let kubeVersionsAvailable = true; | ||
|
||
mainEvents.on('diagnostics-event', (payload) => { | ||
if (payload.id !== 'kube-versions-available') { | ||
return; | ||
} | ||
kubeVersionsAvailable = payload.available; | ||
mainEvents.invoke('diagnostics-trigger', instance.id); | ||
}); | ||
|
||
/** | ||
* KubeVersionsAvailable is a diagnostic that will be emitted when all of the | ||
* following are met: | ||
* - Kubernetes was configured to be enabled | ||
* - The selected Kubernetes version is unavailable (e.g. user is offline) | ||
* Once the diagnostic is triggered, it stays on until the backend is restarted. | ||
*/ | ||
class KubeVersionsAvailable implements DiagnosticsChecker { | ||
readonly id = 'KUBE_VERSIONS_AVAILABLE'; | ||
readonly category = DiagnosticsCategory.Kubernetes; | ||
applicable(): Promise<boolean> { | ||
return Promise.resolve(true); | ||
} | ||
|
||
check(): Promise<DiagnosticsCheckerResult> { | ||
const description = [ | ||
'There are no issues with Kubernetes versions', | ||
'Kubernetes has been disabled due to issues with fetching Kubernetes versions', | ||
][kubeVersionsAvailable ? 0 : 1]; | ||
|
||
return Promise.resolve({ | ||
passed: kubeVersionsAvailable, | ||
description, | ||
fixes: [{ description: 'Check your network connection to update.k3s.io' }], | ||
}); | ||
} | ||
} | ||
|
||
const instance = new KubeVersionsAvailable(); | ||
|
||
export default instance; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters