mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Broadcast cluster's disconnected state before stopping KubeAuthProxy
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
10e4416b07
commit
7908003467
@ -312,6 +312,8 @@ utils.describeIf(minikubeReady(TEST_NAMESPACE))("Minikube based tests", () => {
|
|||||||
}, 10*60*1000);
|
}, 10*60*1000);
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
|
await frame.click(`[data-testid="sidebar-cluster-dropdown"]`);
|
||||||
|
await frame.click(`.Menu >> text="Disconnect"`);
|
||||||
await cleanup();
|
await cleanup();
|
||||||
}, 10*60*1000);
|
}, 10*60*1000);
|
||||||
|
|
||||||
@ -321,6 +323,7 @@ utils.describeIf(minikubeReady(TEST_NAMESPACE))("Minikube based tests", () => {
|
|||||||
await frame.waitForSelector(`.Menu >> text="Settings"`);
|
await frame.waitForSelector(`.Menu >> text="Settings"`);
|
||||||
await frame.waitForSelector(`.Menu >> text="Disconnect"`);
|
await frame.waitForSelector(`.Menu >> text="Disconnect"`);
|
||||||
await frame.waitForSelector(`.Menu >> text="Delete"`);
|
await frame.waitForSelector(`.Menu >> text="Delete"`);
|
||||||
|
await frame.click(`[data-testid="sidebar-cluster-dropdown"]`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should navigate around common cluster pages", async () => {
|
it("should navigate around common cluster pages", async () => {
|
||||||
|
|||||||
@ -56,7 +56,12 @@ export async function start() {
|
|||||||
...process.env,
|
...process.env,
|
||||||
},
|
},
|
||||||
timeout: 100_000,
|
timeout: 100_000,
|
||||||
} as Parameters<typeof electron["launch"]>[0]);
|
});
|
||||||
|
|
||||||
|
const cleanup = async () => {
|
||||||
|
await app.close();
|
||||||
|
await remove(CICD).catch(noop);
|
||||||
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const window = await getMainWindow(app);
|
const window = await getMainWindow(app);
|
||||||
@ -64,14 +69,10 @@ export async function start() {
|
|||||||
return {
|
return {
|
||||||
app,
|
app,
|
||||||
window,
|
window,
|
||||||
cleanup: async () => {
|
cleanup,
|
||||||
await app.close();
|
|
||||||
await remove(CICD).catch(noop);
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
await app.close();
|
await cleanup();
|
||||||
await remove(CICD).catch(noop);
|
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -375,9 +375,13 @@ export class Cluster implements ClusterModel, ClusterState {
|
|||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
@action disconnect() {
|
@action disconnect() {
|
||||||
logger.info(`[CLUSTER]: disconnecting`, { id: this.id });
|
logger.info(`[CLUSTER]: disconnecting cluster`, { id: this.id });
|
||||||
|
|
||||||
|
ipcMain.once(`cluster:${this.id}:frame-removed`, () => {
|
||||||
|
this.contextHandler?.stopServer();
|
||||||
|
});
|
||||||
|
|
||||||
this.eventsDisposer();
|
this.eventsDisposer();
|
||||||
this.contextHandler?.stopServer();
|
|
||||||
this.disconnected = true;
|
this.disconnected = true;
|
||||||
this.online = false;
|
this.online = false;
|
||||||
this.accessible = false;
|
this.accessible = false;
|
||||||
|
|||||||
@ -20,6 +20,8 @@ jest.mock("winston", () => ({
|
|||||||
label: jest.fn(),
|
label: jest.fn(),
|
||||||
timestamp: jest.fn(),
|
timestamp: jest.fn(),
|
||||||
printf: jest.fn(),
|
printf: jest.fn(),
|
||||||
|
padLevels: jest.fn(),
|
||||||
|
ms: jest.fn(),
|
||||||
},
|
},
|
||||||
createLogger: jest.fn().mockReturnValue(logger),
|
createLogger: jest.fn().mockReturnValue(logger),
|
||||||
transports: {
|
transports: {
|
||||||
@ -32,6 +34,23 @@ jest.mock("../../common/ipc");
|
|||||||
jest.mock("request");
|
jest.mock("request");
|
||||||
jest.mock("request-promise-native");
|
jest.mock("request-promise-native");
|
||||||
|
|
||||||
|
jest.mock("electron", () => ({
|
||||||
|
app: {
|
||||||
|
getVersion: () => "99.99.99",
|
||||||
|
getName: () => "lens",
|
||||||
|
setName: jest.fn(),
|
||||||
|
setPath: jest.fn(),
|
||||||
|
getPath: () => "tmp",
|
||||||
|
getLocale: () => "en",
|
||||||
|
setLoginItemSettings: jest.fn(),
|
||||||
|
},
|
||||||
|
ipcMain: {
|
||||||
|
on: jest.fn(),
|
||||||
|
once: jest.fn(),
|
||||||
|
handle: jest.fn(),
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
import { Console } from "console";
|
import { Console } from "console";
|
||||||
import mockFs from "mock-fs";
|
import mockFs from "mock-fs";
|
||||||
import type { Cluster } from "../../common/cluster/cluster";
|
import type { Cluster } from "../../common/cluster/cluster";
|
||||||
|
|||||||
@ -30,6 +30,7 @@ jest.mock("electron", () => ({
|
|||||||
},
|
},
|
||||||
ipcMain: {
|
ipcMain: {
|
||||||
on: jest.fn(),
|
on: jest.fn(),
|
||||||
|
once: jest.fn(),
|
||||||
handle: jest.fn(),
|
handle: jest.fn(),
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|||||||
@ -107,7 +107,7 @@ export class KubeAuthProxy {
|
|||||||
this.ready = false;
|
this.ready = false;
|
||||||
|
|
||||||
if (this.proxyProcess) {
|
if (this.proxyProcess) {
|
||||||
logger.debug("[KUBE-AUTH]: stopping local proxy", this.cluster.getMeta());
|
logger.info("[KUBE-AUTH]: stopping local proxy", { clusterId: this.cluster.id });
|
||||||
this.proxyProcess.removeAllListeners();
|
this.proxyProcess.removeAllListeners();
|
||||||
this.proxyProcess.stderr.removeAllListeners();
|
this.proxyProcess.stderr.removeAllListeners();
|
||||||
this.proxyProcess.stdout.removeAllListeners();
|
this.proxyProcess.stdout.removeAllListeners();
|
||||||
|
|||||||
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
import { action, IReactionDisposer, makeObservable, observable, when } from "mobx";
|
import { action, IReactionDisposer, makeObservable, observable, when } from "mobx";
|
||||||
import logger from "../../../main/logger";
|
import logger from "../../../main/logger";
|
||||||
|
import { broadcastMessage } from "../../../common/ipc";
|
||||||
import { clusterVisibilityHandler } from "../../../common/cluster-ipc";
|
import { clusterVisibilityHandler } from "../../../common/cluster-ipc";
|
||||||
import { ClusterStore } from "../../../common/cluster-store/cluster-store";
|
import { ClusterStore } from "../../../common/cluster-store/cluster-store";
|
||||||
import type { ClusterId } from "../../../common/cluster-types";
|
import type { ClusterId } from "../../../common/cluster-types";
|
||||||
@ -72,6 +73,7 @@ export class ClusterFrameHandler extends Singleton {
|
|||||||
logger.info(`[LENS-VIEW]: remove dashboard, clusterId=${clusterId}`);
|
logger.info(`[LENS-VIEW]: remove dashboard, clusterId=${clusterId}`);
|
||||||
this.views.delete(clusterId);
|
this.views.delete(clusterId);
|
||||||
iframe.parentNode.removeChild(iframe);
|
iframe.parentNode.removeChild(iframe);
|
||||||
|
broadcastMessage(`cluster:${clusterId}:frame-removed`);
|
||||||
dispose();
|
dispose();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user