Fix kubeconfig-sync sometimes producing multiple identical entities (#5855)

This commit is contained in:
Sebastian Malton authored and GitHub committed 2022-10-03 10:38:41 -04:00
1 parent e6396b7314
commit b9cc0d5687
109 files changed
+1219 -505

No files matched your search

@@ -14,6 +14,7 @@ const setupListenerForCurrentClusterFrameInjectable = getInjectable({
id: "setup-listener-for-current-cluster-frame",
instantiate: (di) => ({
id: "setup-listener-for-current-cluster-frame",
run: () => {
const currentClusterFrameState = di.inject(currentClusterFrameClusterIdStateInjectable);
@@ -10,6 +10,7 @@ const cleanUpShellSessionsInjectable = getInjectable({
id: "clean-up-shell-sessions",
instantiate: () => ({
id: "clean-up-shell-sessions",
run: () => {
ShellSession.cleanup();
},
@@ -13,6 +13,7 @@ const emitCloseToEventBusInjectable = getInjectable({
const appEventBus = di.inject(appEventBusInjectable);
return {
id: "emit-close-to-event-bus",
run: () => {
appEventBus.emit({ name: "app", action: "close" });
},
@@ -13,6 +13,7 @@ const emitServiceStartToEventBusInjectable = getInjectable({
const appEventBus = di.inject(appEventBusInjectable);
return {
id: "emit-service-start-to-event-bus",
run: () => {
appEventBus.emit({ name: "service", action: "start" });
},
@@ -14,6 +14,7 @@ const flagRendererAsLoadedInjectable = getInjectable({
const lensProtocolRouterMain = di.inject(lensProtocolRouterMainInjectable);
return {
id: "flag-renderer-as-loaded",
run: () => {
runInAction(() => {
// Todo: remove this kludge which enables out-of-place temporal dependency.
@@ -14,6 +14,7 @@ const flagRendererAsNotLoadedInjectable = getInjectable({
const lensProtocolRouterMain = di.inject(lensProtocolRouterMainInjectable);
return {
id: "stop-deep-linking",
run: () => {
runInAction(() => {
// Todo: remove this kludge which enables out-of-place temporal dependency.
@@ -21,6 +21,7 @@ const initializeExtensionsInjectable = getInjectable({
const showErrorPopup = di.inject(showErrorPopupInjectable);
return {
id: "initialize-extensions",
run: async () => {
logger.info("🧩 Initializing extensions");
@@ -0,0 +1,26 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import kubeconfigSyncManagerInjectable from "../../../catalog-sources/kubeconfig-sync/manager.injectable";
import catalogEntityRegistryInjectable from "../../../catalog/entity-registry.injectable";
import { afterApplicationIsLoadedInjectionToken } from "../../runnable-tokens/after-application-is-loaded-injection-token";
const addKubeconfigSyncAsEntitySourceInjectable = getInjectable({
id: "add-kubeconfig-sync-as-entity-source",
instantiate: (di) => {
const kubeConfigSyncManager = di.inject(kubeconfigSyncManagerInjectable);
const entityRegistry = di.inject(catalogEntityRegistryInjectable);
return {
id: "add-kubeconfig-sync-as-entity-source",
run: () => {
entityRegistry.addComputedSource("kubeconfig-sync", kubeConfigSyncManager.source);
},
};
},
injectionToken: afterApplicationIsLoadedInjectionToken,
});
export default addKubeconfigSyncAsEntitySourceInjectable;
@@ -7,6 +7,7 @@ import { afterApplicationIsLoadedInjectionToken } from "../../runnable-tokens/af
import directoryForKubeConfigsInjectable from "../../../../common/app-paths/directory-for-kube-configs/directory-for-kube-configs.injectable";
import ensureDirInjectable from "../../../../common/fs/ensure-dir.injectable";
import kubeconfigSyncManagerInjectable from "../../../catalog-sources/kubeconfig-sync/manager.injectable";
import addKubeconfigSyncAsEntitySourceInjectable from "./add-source.injectable";
const startKubeConfigSyncInjectable = getInjectable({
id: "start-kubeconfig-sync",
@@ -17,11 +18,13 @@ const startKubeConfigSyncInjectable = getInjectable({
const ensureDir = di.inject(ensureDirInjectable);
return {
id: "start-kubeconfig-sync",
run: async () => {
await ensureDir(directoryForKubeConfigs);
kubeConfigSyncManager.startSync();
},
runAfter: di.inject(addKubeconfigSyncAsEntitySourceInjectable),
};
},
@@ -13,6 +13,7 @@ const stopKubeConfigSyncInjectable = getInjectable({
const kubeConfigSyncManager = di.inject(kubeconfigSyncManagerInjectable);
return {
id: "stop-kube-config-sync",
run: () => {
kubeConfigSyncManager.stopSync();
},
@@ -14,6 +14,7 @@ const setupSentryInjectable = getInjectable({
const initializeSentryOnMain = di.inject(initializeSentryOnMainInjectable);
return {
id: "setup-sentry",
run: () => initializeSentryReportingWith(initializeSentryOnMain),
};
},
@@ -18,6 +18,7 @@ const setupDetectorRegistryInjectable = getInjectable({
const detectorRegistry = di.inject(detectorRegistryInjectable);
return {
id: "setup-detector-registry",
run: () => {
detectorRegistry
.add(ClusterIdDetector)
@@ -15,6 +15,7 @@ const setupHardwareAccelerationInjectable = getInjectable({
const disableHardwareAcceleration = di.inject(disableHardwareAccelerationInjectable);
return {
id: "setup-hardware-acceleration",
run: () => {
if (hardwareAccelerationShouldBeDisabled) {
disableHardwareAcceleration();
@@ -11,6 +11,7 @@ const setupHotbarStoreInjectable = getInjectable({
id: "setup-hotbar-store",
instantiate: (di) => ({
id: "setup-hotbar-store",
run: () => {
const hotbarStore = di.inject(hotbarStoreInjectable);
@@ -10,6 +10,7 @@ const setupImmerInjectable = getInjectable({
id: "setup-immer",
instantiate: () => ({
id: "setup-immer",
run: () => {
// Docs: https://immerjs.github.io/immer/
// Required in `utils/storage-helper.ts`
@@ -26,6 +26,7 @@ const setupLensProxyInjectable = getInjectable({
const buildVersion = di.inject(buildVersionInjectable);
return {
id: "setup-lens-proxy",
run: async () => {
try {
logger.info("🔌 Starting LensProxy");
@@ -10,6 +10,7 @@ const setupMobxInjectable = getInjectable({
id: "setup-mobx",
instantiate: () => ({
id: "setup-mobx",
run: () => {
// Docs: https://mobx.js.org/configuration.html
Mobx.configure({
@@ -18,6 +18,7 @@ const setupPrometheusRegistryInjectable = getInjectable({
const prometheusProviderRegistry = di.inject(prometheusProviderRegistryInjectable);
return {
id: "setup-prometheus-registry",
run: () => {
prometheusProviderRegistry
.registerProvider(new PrometheusLens())
@@ -13,6 +13,7 @@ const setupProxyEnvInjectable = getInjectable({
const getCommandLineSwitch = di.inject(getCommandLineSwitchInjectable);
return {
id: "setup-proxy-env",
run: () => {
const switchValue = getCommandLineSwitch("proxy-server");
@@ -13,6 +13,7 @@ const setupReactionsInUserStoreInjectable = getInjectable({
const userStore = di.inject(userStoreInjectable);
return {
id: "setup-reactions-in-user-store",
run: () => {
userStore.startMainReactions();
},
@@ -20,6 +20,7 @@ const setupShellInjectable = getInjectable({
const electronApp = di.inject(electronAppInjectable);
return {
id: "setup-shell",
run: async () => {
logger.info("🐚 Syncing shell environment");
@@ -15,6 +15,7 @@ const setupSyncingOfGeneralCatalogEntitiesInjectable = getInjectable({
);
return {
id: "setup-syncing-of-general-catalog-entities",
run: () => {
syncGeneralCatalogEntities();
},
@@ -13,6 +13,7 @@ const setupSyncingOfWeblinksInjectable = getInjectable({
const syncWeblinks = di.inject(syncWeblinksInjectable);
return {
id: "setup-syncing-of-weblinks",
run: () => {
syncWeblinks();
},
@@ -10,6 +10,7 @@ const setupSystemCaInjectable = getInjectable({
id: "setup-system-ca",
instantiate: () => ({
id: "setup-system-ca",
run: async () => {
await injectSystemCAs();
},
@@ -3,7 +3,7 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import clusterManagerInjectable from "../../cluster-manager.injectable";
import clusterManagerInjectable from "../../cluster/manager.injectable";
import { beforeQuitOfFrontEndInjectionToken } from "../runnable-tokens/before-quit-of-front-end-injection-token";
const stopClusterManagerInjectable = getInjectable({
@@ -13,6 +13,7 @@ const stopClusterManagerInjectable = getInjectable({
const clusterManager = di.inject(clusterManagerInjectable);
return {
id: "stop-cluster-manager",
run: () => {
clusterManager.stop();
},