Mark cluster as dead if kubeconfig loading fails

Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
This commit is contained in:
Lauri Nevala committed 2021-01-14 14:57:25 +02:00
1 parent be0ce02448
commit 7baaec5d27
3 files changed
+49 -21

No files matched your search

+13 -2
View File
@@ -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;
}
}