From da125ece8d3e8858e76dca257f21dd07cb29b8d1 Mon Sep 17 00:00:00 2001 From: Juozas Gaigalas Date: Thu, 28 Sep 2023 17:26:09 +0300 Subject: [PATCH] dont resurrect deactivated kubectl proxy (#491) Signed-off-by: Juozas Gaigalas --- src/cli/kubernetes/kubectlProxy.ts | 3 ++- src/extension.ts | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cli/kubernetes/kubectlProxy.ts b/src/cli/kubernetes/kubectlProxy.ts index 0efaa648..b5ced2fb 100644 --- a/src/cli/kubernetes/kubectlProxy.ts +++ b/src/cli/kubernetes/kubectlProxy.ts @@ -1,6 +1,7 @@ import { KubeConfig } from '@kubernetes/client-node'; import { ChildProcess } from 'child_process'; import * as shell from 'cli/shell/exec'; +import { isActive } from 'extension'; import { createK8sClients, destroyK8sClients } from 'k8s/client'; import { createProxyConfig } from 'k8s/createKubeProxyConfig'; @@ -14,7 +15,7 @@ export let kubeProxyConfig: KubeConfig | undefined; export function kubeProxyKeepAlive() { // keep alive setInterval(async () => { - if(!proxyProc) { + if(!proxyProc && isActive) { destroyK8sClients(); await startKubeProxy(); } diff --git a/src/extension.ts b/src/extension.ts index 223de489..2f007004 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -30,6 +30,7 @@ export let extensionContext: ExtensionContext; export let globalState: GlobalState; /** Methods to report telemetry over Application Insights (Exceptions or Custom Events). */ export let telemetry: Telemetry | any; +export let isActive = true; /** * Called when GitOps extension is activated. @@ -128,6 +129,7 @@ export function suppressDebugMessages(): boolean { * Called when extension is deactivated. */ export function deactivate() { + isActive = false; telemetry?.dispose(); statusBar?.dispose(); stopKubeProxy();