1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Remove dead "force activate" code

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2023-03-14 09:59:13 -04:00
parent 21352b3c6d
commit 9cbe7d5078
5 changed files with 17 additions and 28 deletions

View File

@ -90,7 +90,7 @@ export class KubernetesCluster<
await connectionCluster.activate(); await connectionCluster.activate();
} else { } else {
await requestClusterActivation(this.getId(), false); await requestClusterActivation(this.getId());
} }
} }
@ -108,7 +108,7 @@ export class KubernetesCluster<
connectionCluster.disconnect(); connectionCluster.disconnect();
} else { } else {
await requestClusterDisconnection(this.getId(), false); await requestClusterDisconnection(this.getId());
} }
} }

View File

@ -104,11 +104,8 @@ class ClusterConnection {
} }
} }
/** async activate() {
* @param force force activation if (this.activated) {
*/
async activate(force = false) {
if (this.activated && !force) {
return; return;
} }
@ -124,7 +121,13 @@ class ClusterConnection {
level: "info", level: "info",
message: "Starting connection ...", message: "Starting connection ...",
}); });
await this.reconnect(); this.dependencies.logger.info("[CLUSTER]: starting connection ...", this.cluster.getMeta());
await this.dependencies.kubeAuthProxyServer.ensureRunning();
runInAction(() => {
this.cluster.disconnected.set(false);
});
} catch (error) { } catch (error) {
this.dependencies.broadcastConnectionUpdate({ this.dependencies.broadcastConnectionUpdate({
level: "error", level: "error",
@ -174,15 +177,6 @@ class ClusterConnection {
this.activated = true; this.activated = true;
} }
async reconnect() {
this.dependencies.logger.info(`[CLUSTER]: reconnect`, this.cluster.getMeta());
await this.dependencies.kubeAuthProxyServer?.restart();
runInAction(() => {
this.cluster.disconnected.set(false);
});
}
disconnect() { disconnect() {
if (this.cluster.disconnected.get()) { if (this.cluster.disconnected.get()) {
return this.dependencies.logger.debug("[CLUSTER]: already disconnected", { id: this.cluster.id }); return this.dependencies.logger.debug("[CLUSTER]: already disconnected", { id: this.cluster.id });

View File

@ -13,7 +13,6 @@ import type { KubeAuthProxy } from "../kube-auth-proxy/kube-auth-proxy";
export interface KubeAuthProxyServer { export interface KubeAuthProxyServer {
getApiTarget(isLongRunningRequest?: boolean): Promise<ServerOptions>; getApiTarget(isLongRunningRequest?: boolean): Promise<ServerOptions>;
ensureAuthProxyUrl(): Promise<string>; ensureAuthProxyUrl(): Promise<string>;
restart(): Promise<void>;
ensureRunning(): Promise<void>; ensureRunning(): Promise<void>;
stop(): void; stop(): void;
} }
@ -99,10 +98,6 @@ const kubeAuthProxyServerInjectable = getInjectable({
ensureRunning: async () => { ensureRunning: async () => {
await ensureServerHelper(); await ensureServerHelper();
}, },
restart: async () => {
stopServer();
await ensureServerHelper();
},
stop: stopServer, stop: stopServer,
}; };
}, },

View File

@ -37,7 +37,7 @@ export const setupIpcMainHandlers = ({
pushCatalogToRenderer, pushCatalogToRenderer,
getClusterConnection, getClusterConnection,
}: Dependencies) => { }: Dependencies) => {
ipcMainHandle(clusterActivateHandler, async (event, clusterId: ClusterId, force = false) => { ipcMainHandle(clusterActivateHandler, async (event, clusterId: ClusterId) => {
const cluster = getClusterById(clusterId); const cluster = getClusterById(clusterId);
if (!cluster) { if (!cluster) {
@ -46,7 +46,7 @@ export const setupIpcMainHandlers = ({
const clusterConnection = getClusterConnection(cluster); const clusterConnection = getClusterConnection(cluster);
await clusterConnection.activate(force); await clusterConnection.activate();
}); });
ipcMainHandle(clusterSetFrameIdHandler, (event: IpcMainInvokeEvent, clusterId: ClusterId) => { ipcMainHandle(clusterSetFrameIdHandler, (event: IpcMainInvokeEvent, clusterId: ClusterId) => {

View File

@ -46,12 +46,12 @@ export function requestSetClusterFrameId(clusterId: ClusterId): Promise<void> {
return requestMain(clusterSetFrameIdHandler, clusterId); return requestMain(clusterSetFrameIdHandler, clusterId);
} }
export function requestClusterActivation(clusterId: ClusterId, force?: boolean): Promise<void> { export function requestClusterActivation(clusterId: ClusterId): Promise<void> {
return requestMain(clusterActivateHandler, clusterId, force); return requestMain(clusterActivateHandler, clusterId);
} }
export function requestClusterDisconnection(clusterId: ClusterId, force?: boolean): Promise<void> { export function requestClusterDisconnection(clusterId: ClusterId): Promise<void> {
return requestMain(clusterDisconnectHandler, clusterId, force); return requestMain(clusterDisconnectHandler, clusterId);
} }
export function requestInitialClusterStates(): Promise<{ id: string; state: ClusterState }[]> { export function requestInitialClusterStates(): Promise<{ id: string; state: ClusterState }[]> {