mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Mark cluster as dead if kubeconfig loading fails
Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
This commit is contained in:
1 parent
be0ce02448
commit
7baaec5d27
3 files changed
+49
-21
No files matched your search
+13
-2
@@ -169,6 +169,12 @@ export class Cluster implements ClusterModel, ClusterState {
|
||||
* @observable
|
||||
*/
|
||||
@observable isAdmin = false;
|
||||
/**
|
||||
* Is cluster marked as dead, for example due the invalid kubeconfig
|
||||
*
|
||||
* @observable
|
||||
*/
|
||||
@observable isDead = false;
|
||||
/**
|
||||
* Preferences
|
||||
*
|
||||
@@ -242,10 +248,15 @@ export class Cluster implements ClusterModel, ClusterState {
|
||||
|
||||
constructor(model: ClusterModel) {
|
||||
this.updateModel(model);
|
||||
const kubeconfig = this.getKubeconfig();
|
||||
|
||||
if (kubeconfig.getContextObject(this.contextName)) {
|
||||
try {
|
||||
const kubeconfig = this.getKubeconfig();
|
||||
|
||||
this.apiUrl = kubeconfig.getCluster(kubeconfig.getContextObject(this.contextName).cluster).server;
|
||||
} catch(err) {
|
||||
logger.error(err);
|
||||
logger.error(`[CLUSTER] Failed to load kubeconfig for the cluster (context: ${this.contextName}, kubeconfig: ${this.kubeConfigPath}).`);
|
||||
this.isDead = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user