From daa4992f2bf0e25052273bec758c190995e639f0 Mon Sep 17 00:00:00 2001 From: Lauri Nevala Date: Mon, 12 Oct 2020 10:10:30 +0300 Subject: [PATCH] Start authentication proxy when opening cluster settings (#1063) Signed-off-by: Lauri Nevala --- src/common/cluster-ipc.ts | 5 ++--- src/main/cluster.ts | 12 ++++++++---- .../+cluster-settings/cluster-settings.tsx | 3 ++- .../components/cluster-manager/cluster-status.tsx | 7 ++++--- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/common/cluster-ipc.ts b/src/common/cluster-ipc.ts index 6ab46c1489..0ff5f41734 100644 --- a/src/common/cluster-ipc.ts +++ b/src/common/cluster-ipc.ts @@ -5,11 +5,10 @@ import { tracker } from "./tracker"; export const clusterIpc = { activate: createIpcChannel({ channel: "cluster:activate", - handle: (clusterId: ClusterId, frameId?: number) => { + handle: (clusterId: ClusterId, force = false) => { const cluster = clusterStore.getById(clusterId); if (cluster) { - if (frameId) cluster.frameId = frameId; // save cluster's webFrame.routingId to be able to send push-updates - return cluster.activate(); + return cluster.activate(force); } }, }), diff --git a/src/main/cluster.ts b/src/main/cluster.ts index f9b3c53ddc..3b9e89ef86 100644 --- a/src/main/cluster.ts +++ b/src/main/cluster.ts @@ -46,6 +46,7 @@ export class Cluster implements ClusterModel { public contextHandler: ContextHandler; protected kubeconfigManager: KubeconfigManager; protected eventDisposers: Function[] = []; + protected activated = false; whenInitialized = when(() => this.initialized); whenReady = when(() => this.ready); @@ -126,7 +127,10 @@ export class Cluster implements ClusterModel { } @action - async activate() { + async activate(force = false ) { + if (this.activated && !force) { + return this.pushState(); + } logger.info(`[CLUSTER]: activate`, this.getMeta()); await this.whenInitialized; if (!this.eventDisposers.length) { @@ -142,6 +146,7 @@ export class Cluster implements ClusterModel { this.kubeCtl = new Kubectl(this.version) this.kubeCtl.ensureKubectl() // download kubectl in background, so it's not blocking dashboard } + this.activated = true return this.pushState(); } @@ -162,6 +167,7 @@ export class Cluster implements ClusterModel { this.online = false; this.accessible = false; this.ready = false; + this.activated = false; this.pushState(); } @@ -184,9 +190,7 @@ export class Cluster implements ClusterModel { this.refreshEvents(), this.refreshAllowedResources(), ]); - if (!this.ready) { - this.ready = true - } + this.ready = true } this.pushState(); } diff --git a/src/renderer/components/+cluster-settings/cluster-settings.tsx b/src/renderer/components/+cluster-settings/cluster-settings.tsx index b284ed9c88..9558b26967 100644 --- a/src/renderer/components/+cluster-settings/cluster-settings.tsx +++ b/src/renderer/components/+cluster-settings/cluster-settings.tsx @@ -46,8 +46,9 @@ export class ClusterSettings extends React.Component { } } - refreshCluster = () => { + refreshCluster = async () => { if(this.cluster) { + await clusterIpc.activate.invokeFromRenderer(this.cluster.id); clusterIpc.refresh.invokeFromRenderer(this.cluster.id); } } diff --git a/src/renderer/components/cluster-manager/cluster-status.tsx b/src/renderer/components/cluster-manager/cluster-status.tsx index 846b26a504..5a488c4405 100644 --- a/src/renderer/components/cluster-manager/cluster-status.tsx +++ b/src/renderer/components/cluster-manager/cluster-status.tsx @@ -47,13 +47,14 @@ export class ClusterStatus extends React.Component { ipcRenderer.removeAllListeners(`kube-auth:${this.props.clusterId}`); } - activateCluster = async () => { - await clusterIpc.activate.invokeFromRenderer(this.props.clusterId); + activateCluster = async (force = false) => { + await clusterIpc.activate.invokeFromRenderer(this.props.clusterId, force); } reconnect = async () => { + this.authOutput = [] this.isReconnecting = true; - await this.activateCluster(); + await this.activateCluster(true); this.isReconnecting = false; }