-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7515 from mook-as/k3s-no-versions-fallback
Fix fallback when Kubernetes versions list is unavailable
- Loading branch information
Showing
10 changed files
with
121 additions
and
35 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
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
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