mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
purge ContextHandler's cache on disconnect
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
f348ca8ff2
commit
529edc46d8
@ -313,6 +313,7 @@ export class Cluster implements ClusterModel, ClusterState {
|
|||||||
if (this.activated && !force) {
|
if (this.activated && !force) {
|
||||||
return this.pushState();
|
return this.pushState();
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info(`[CLUSTER]: activate`, this.getMeta());
|
logger.info(`[CLUSTER]: activate`, this.getMeta());
|
||||||
|
|
||||||
if (!this.eventDisposers.length) {
|
if (!this.eventDisposers.length) {
|
||||||
@ -330,7 +331,7 @@ export class Cluster implements ClusterModel, ClusterState {
|
|||||||
}
|
}
|
||||||
this.activated = true;
|
this.activated = true;
|
||||||
|
|
||||||
return this.pushState();
|
this.pushState();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -9,12 +9,11 @@ import logger from "./logger";
|
|||||||
import { KubeAuthProxy } from "./kube-auth-proxy";
|
import { KubeAuthProxy } from "./kube-auth-proxy";
|
||||||
|
|
||||||
export class ContextHandler {
|
export class ContextHandler {
|
||||||
public proxyPort: number;
|
|
||||||
public clusterUrl: UrlWithStringQuery;
|
public clusterUrl: UrlWithStringQuery;
|
||||||
protected kubeAuthProxy: KubeAuthProxy;
|
protected kubeAuthProxy?: KubeAuthProxy;
|
||||||
protected apiTarget: httpProxy.ServerOptions;
|
protected apiTarget?: httpProxy.ServerOptions;
|
||||||
protected prometheusProvider: string;
|
protected prometheusProvider: string;
|
||||||
protected prometheusPath: string;
|
protected prometheusPath: string | null;
|
||||||
|
|
||||||
constructor(protected cluster: Cluster) {
|
constructor(protected cluster: Cluster) {
|
||||||
this.clusterUrl = url.parse(cluster.apiUrl);
|
this.clusterUrl = url.parse(cluster.apiUrl);
|
||||||
@ -83,24 +82,18 @@ export class ContextHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getApiTarget(isWatchRequest = false): Promise<httpProxy.ServerOptions> {
|
async getApiTarget(isWatchRequest = false): Promise<httpProxy.ServerOptions> {
|
||||||
if (this.apiTarget && !isWatchRequest) {
|
|
||||||
return this.apiTarget;
|
|
||||||
}
|
|
||||||
const timeout = isWatchRequest ? 4 * 60 * 60 * 1000 : 30000; // 4 hours for watch request, 30 seconds for the rest
|
const timeout = isWatchRequest ? 4 * 60 * 60 * 1000 : 30000; // 4 hours for watch request, 30 seconds for the rest
|
||||||
const apiTarget = await this.newApiTarget(timeout);
|
|
||||||
|
|
||||||
if (!isWatchRequest) {
|
if (isWatchRequest) {
|
||||||
this.apiTarget = apiTarget;
|
return this.newApiTarget(timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
return apiTarget;
|
return this.apiTarget ??= await this.newApiTarget(timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async newApiTarget(timeout: number): Promise<httpProxy.ServerOptions> {
|
protected async newApiTarget(timeout: number): Promise<httpProxy.ServerOptions> {
|
||||||
const proxyUrl = await this.resolveAuthProxyUrl();
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
target: proxyUrl,
|
target: await this.resolveAuthProxyUrl(),
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
timeout,
|
timeout,
|
||||||
headers: {
|
headers: {
|
||||||
@ -122,10 +115,9 @@ export class ContextHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stopServer() {
|
stopServer() {
|
||||||
if (this.kubeAuthProxy) {
|
this.kubeAuthProxy?.exit();
|
||||||
this.kubeAuthProxy.exit();
|
this.kubeAuthProxy = undefined;
|
||||||
this.kubeAuthProxy = null;
|
this.apiTarget = undefined;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get proxyLastError(): string {
|
get proxyLastError(): string {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user