diff --git a/src/common/cluster-store.ts b/src/common/cluster-store.ts index 2eae7da6a8..6bf932f0f4 100644 --- a/src/common/cluster-store.ts +++ b/src/common/cluster-store.ts @@ -323,7 +323,7 @@ export class ClusterStore extends BaseStore { } else { cluster = new Cluster(clusterModel); - if (!cluster.isManaged && !cluster.isDead) { + if (!cluster.isManaged && cluster.apiUrl) { cluster.enabled = true; } } @@ -337,7 +337,7 @@ export class ClusterStore extends BaseStore { } }); - this.activeCluster = newClusters.has(activeCluster) && newClusters.get(activeCluster).enabled ? activeCluster : null; + this.activeCluster = newClusters.get(activeCluster)?.enabled ? activeCluster : null; this.clusters.replace(newClusters); this.removedClusters.replace(removedClusters); } diff --git a/src/common/kube-helpers.ts b/src/common/kube-helpers.ts index 3cf4fda6de..c2a2a8df93 100644 --- a/src/common/kube-helpers.ts +++ b/src/common/kube-helpers.ts @@ -157,8 +157,7 @@ export function getNodeWarningConditions(node: V1Node) { } /** - * Validates Context, User and Cluster sructs in given kubeconfig. Additionally this will validate - * the command passed to the exec substructure. + * Checks if `config` has valid `Context`, `User`, `Cluster`, and `exec` fields (if present when required) */ export function validateKubeConfig (config: KubeConfig, contextName: string, validationOpts: KubeConfigValidationOpts = {}) { // we only receive a single context, cluster & user object here so lets validate them as this diff --git a/src/main/cluster.ts b/src/main/cluster.ts index 19809a0811..198d24c2f9 100644 --- a/src/main/cluster.ts +++ b/src/main/cluster.ts @@ -77,7 +77,6 @@ export class Cluster implements ClusterModel, ClusterState { * If extension sets this it needs to also mark cluster as enabled on activate (or when added to a store) */ public ownerRef: string; - public isDead = false; protected kubeconfigManager: KubeconfigManager; protected eventDisposers: Function[] = []; protected activated = false; @@ -268,7 +267,6 @@ export class Cluster implements ClusterModel, ClusterState { logger.error(err); logger.error(`[CLUSTER] Failed to load kubeconfig for the cluster '${this.name || this.contextName}' (context: ${this.contextName}, kubeconfig: ${this.kubeConfigPath}).`); broadcastMessage(InvalidKubeconfigChannel, model.id); - this.isDead = true; } }