Revert "Renderer file logging through IPC" (#7393)

This reverts commit 48db54ec9e.
This commit is contained in:
Sebastian Malton authored and GitHub committed 2023-03-21 16:13:27 -04:00
1 parent 48db54ec9e
commit 5409324236
24 files changed
+72 -832

No files matched your search

@@ -22,51 +22,62 @@ interface Dependencies {
const logPrefix = "[CLUSTER-FRAME]:";
export const initClusterFrame =
({
hostedCluster,
loadExtensions,
catalogEntityRegistry,
frameRoutingId,
emitAppEvent,
logger,
showErrorNotification,
}: Dependencies) =>
async () => {
export const initClusterFrame = ({
hostedCluster,
loadExtensions,
catalogEntityRegistry,
frameRoutingId,
emitAppEvent,
logger,
showErrorNotification,
}: Dependencies) =>
async (unmountRoot: () => void) => {
// TODO: Make catalogEntityRegistry already initialized when passed as dependency
catalogEntityRegistry.init();
catalogEntityRegistry.init();
logger.info(
`${logPrefix} Init dashboard, clusterId=${hostedCluster.id}, frameId=${frameRoutingId}`,
);
logger.info(
`${logPrefix} Init dashboard, clusterId=${hostedCluster.id}, frameId=${frameRoutingId}`,
);
await requestSetClusterFrameId(hostedCluster.id);
await when(() => hostedCluster.ready.get()); // cluster.activate() is done at this point
await requestSetClusterFrameId(hostedCluster.id);
await when(() => hostedCluster.ready.get()); // cluster.activate() is done at this point
catalogEntityRegistry.activeEntity = hostedCluster.id;
catalogEntityRegistry.activeEntity = hostedCluster.id;
// Only load the extensions once the catalog has been populated.
// Note that the Catalog might still have unprocessed entities until the extensions are fully loaded.
when(
() => catalogEntityRegistry.items.get().length > 0,
() => loadExtensions(),
{
timeout: 15_000,
onError: (error) => {
logger.warn("[CLUSTER-FRAME]: error from activeEntity when()", error);
// Only load the extensions once the catalog has been populated.
// Note that the Catalog might still have unprocessed entities until the extensions are fully loaded.
when(
() => catalogEntityRegistry.items.get().length > 0,
() =>
loadExtensions(),
{
timeout: 15_000,
onError: (error) => {
logger.warn(
"[CLUSTER-FRAME]: error from activeEntity when()",
error,
);
showErrorNotification("Failed to get KubernetesCluster for this view. Extensions will not be loaded.");
},
showErrorNotification("Failed to get KubernetesCluster for this view. Extensions will not be loaded.");
},
},
);
setTimeout(() => {
emitAppEvent({
name: "cluster",
action: "open",
params: {
clusterId: hostedCluster.id,
},
});
});
window.onbeforeunload = () => {
logger.info(
`${logPrefix} Unload dashboard, clusterId=${(hostedCluster.id)}, frameId=${frameRoutingId}`,
);
setTimeout(() => {
emitAppEvent({
name: "cluster",
action: "open",
params: {
clusterId: hostedCluster.id,
},
});
});
unmountRoot();
};
};
@@ -9,6 +9,7 @@ import lensProtocolRouterRendererInjectable from "../../protocol-handler/lens-pr
import catalogEntityRegistryInjectable from "../../api/catalog/entity/registry.injectable";
import registerIpcListenersInjectable from "../../ipc/register-ipc-listeners.injectable";
import loadExtensionsInjectable from "../load-extensions.injectable";
import loggerInjectable from "../../../common/logger.injectable";
import { delay } from "@k8slens/utilities";
import { broadcastMessage } from "../../../common/ipc";
import { bundledExtensionsLoaded } from "../../../common/ipc/extension-handling";
@@ -22,8 +23,9 @@ const initRootFrameInjectable = getInjectable({
const bindProtocolAddRouteHandlers = di.inject(bindProtocolAddRouteHandlersInjectable);
const lensProtocolRouterRenderer = di.inject(lensProtocolRouterRendererInjectable);
const catalogEntityRegistry = di.inject(catalogEntityRegistryInjectable);
const logger = di.inject(loggerInjectable);
return async () => {
return async (unmountRoot: () => void) => {
catalogEntityRegistry.init();
try {
@@ -54,6 +56,12 @@ const initRootFrameInjectable = getInjectable({
window.addEventListener("online", () => broadcastMessage("network:online"));
registerIpcListeners();
window.addEventListener("beforeunload", () => {
logger.info("[ROOT-FRAME]: Unload app");
unmountRoot();
});
};
},
});