From 6971f140026e46ed6e26e97cfacc622c81dbed78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20W=C3=BCthrich?= Date: Thu, 7 Jan 2021 06:29:12 +0100 Subject: [PATCH 1/9] Fix typo in prometheus ingress metrics (#1896) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Hannes Wüthrich --- src/main/prometheus/lens.ts | 4 ++-- src/main/prometheus/operator.ts | 4 ++-- src/main/prometheus/stacklight.ts | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/prometheus/lens.ts b/src/main/prometheus/lens.ts index b829285f33..2d85a5a0a2 100644 --- a/src/main/prometheus/lens.ts +++ b/src/main/prometheus/lens.ts @@ -75,8 +75,8 @@ export class PrometheusLens implements PrometheusProvider { `sum(rate(nginx_ingress_controller_bytes_sent_sum{ingress="${ingress}", status=~"${statuses}"}[${this.rateAccuracy}])) by (ingress)`; return { - bytesSentSuccess: bytesSent(opts.igress, "^2\\\\d*"), - bytesSentFailure: bytesSent(opts.ingres, "^5\\\\d*"), + bytesSentSuccess: bytesSent(opts.ingress, "^2\\\\d*"), + bytesSentFailure: bytesSent(opts.ingress, "^5\\\\d*"), requestDurationSeconds: `sum(rate(nginx_ingress_controller_request_duration_seconds_sum{ingress="${opts.ingress}"}[${this.rateAccuracy}])) by (ingress)`, responseDurationSeconds: `sum(rate(nginx_ingress_controller_response_duration_seconds_sum{ingress="${opts.ingress}"}[${this.rateAccuracy}])) by (ingress)` }; diff --git a/src/main/prometheus/operator.ts b/src/main/prometheus/operator.ts index ee4c1e63bf..3e7bff071e 100644 --- a/src/main/prometheus/operator.ts +++ b/src/main/prometheus/operator.ts @@ -85,8 +85,8 @@ export class PrometheusOperator implements PrometheusProvider { `sum(rate(nginx_ingress_controller_bytes_sent_sum{ingress="${ingress}", status=~"${statuses}"}[${this.rateAccuracy}])) by (ingress)`; return { - bytesSentSuccess: bytesSent(opts.igress, "^2\\\\d*"), - bytesSentFailure: bytesSent(opts.ingres, "^5\\\\d*"), + bytesSentSuccess: bytesSent(opts.ingress, "^2\\\\d*"), + bytesSentFailure: bytesSent(opts.ingress, "^5\\\\d*"), requestDurationSeconds: `sum(rate(nginx_ingress_controller_request_duration_seconds_sum{ingress="${opts.ingress}"}[${this.rateAccuracy}])) by (ingress)`, responseDurationSeconds: `sum(rate(nginx_ingress_controller_response_duration_seconds_sum{ingress="${opts.ingress}"}[${this.rateAccuracy}])) by (ingress)` }; diff --git a/src/main/prometheus/stacklight.ts b/src/main/prometheus/stacklight.ts index 5cb2773ca5..07ac8f6668 100644 --- a/src/main/prometheus/stacklight.ts +++ b/src/main/prometheus/stacklight.ts @@ -75,8 +75,8 @@ export class PrometheusStacklight implements PrometheusProvider { `sum(rate(nginx_ingress_controller_bytes_sent_sum{ingress="${ingress}", status=~"${statuses}"}[${this.rateAccuracy}])) by (ingress)`; return { - bytesSentSuccess: bytesSent(opts.igress, "^2\\\\d*"), - bytesSentFailure: bytesSent(opts.ingres, "^5\\\\d*"), + bytesSentSuccess: bytesSent(opts.ingress, "^2\\\\d*"), + bytesSentFailure: bytesSent(opts.ingress, "^5\\\\d*"), requestDurationSeconds: `sum(rate(nginx_ingress_controller_request_duration_seconds_sum{ingress="${opts.ingress}"}[${this.rateAccuracy}])) by (ingress)`, responseDurationSeconds: `sum(rate(nginx_ingress_controller_response_duration_seconds_sum{ingress="${opts.ingress}"}[${this.rateAccuracy}])) by (ingress)` }; From fa971aef5c23fe74c7197abf473bf32b11fc0e51 Mon Sep 17 00:00:00 2001 From: Jari Kolehmainen Date: Thu, 7 Jan 2021 13:06:23 +0200 Subject: [PATCH 2/9] Catch xtermjs fit error (#1907) Signed-off-by: Jari Kolehmainen --- src/renderer/components/dock/terminal.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/renderer/components/dock/terminal.ts b/src/renderer/components/dock/terminal.ts index a4246658fe..6de16721d6 100644 --- a/src/renderer/components/dock/terminal.ts +++ b/src/renderer/components/dock/terminal.ts @@ -130,10 +130,17 @@ export class Terminal { fit = () => { // Since this function is debounced we need to read this value as late as possible if (!this.isActive) return; - this.fitAddon.fit(); - const { cols, rows } = this.xterm; - this.api.sendTerminalSize(cols, rows); + try { + this.fitAddon.fit(); + const { cols, rows } = this.xterm; + + this.api.sendTerminalSize(cols, rows); + } catch(error) { + console.error(error); + + return; // see https://github.com/lensapp/lens/issues/1891 + } }; fitLazy = debounce(this.fit, 250); From 4843732ad94a2d965df6e9d992ee06b8518b4b71 Mon Sep 17 00:00:00 2001 From: Jari Kolehmainen Date: Fri, 8 Jan 2021 16:44:33 +0200 Subject: [PATCH 3/9] Fix windows tray icon click (#1908) Signed-off-by: Jari Kolehmainen --- src/main/tray.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/main/tray.ts b/src/main/tray.ts index 50df26cb8f..47f641ad72 100644 --- a/src/main/tray.ts +++ b/src/main/tray.ts @@ -10,7 +10,7 @@ import { workspaceStore } from "../common/workspace-store"; import { preferencesURL } from "../renderer/components/+preferences/preferences.route"; import { clusterViewURL } from "../renderer/components/cluster-manager/cluster-view.route"; import logger from "./logger"; -import { isDevelopment } from "../common/vars"; +import { isDevelopment, isWindows } from "../common/vars"; import { exitApp } from "./exit-app"; // note: instance of Tray should be saved somewhere, otherwise it disappears @@ -29,7 +29,7 @@ export function initTray(windowManager: WindowManager) { try { const menu = createTrayMenu(windowManager); - buildTray(getTrayIcon(), menu); + buildTray(getTrayIcon(), menu, windowManager); } catch (err) { logger.error(`[TRAY]: building failed: ${err}`); } @@ -42,20 +42,25 @@ export function initTray(windowManager: WindowManager) { }; } -export function buildTray(icon: string | NativeImage, menu: Menu) { +function buildTray(icon: string | NativeImage, menu: Menu, windowManager: WindowManager) { if (!tray) { tray = new Tray(icon); tray.setToolTip(packageInfo.description); tray.setIgnoreDoubleClickEvents(true); - } + tray.setImage(icon); + tray.setContextMenu(menu); - tray.setImage(icon); - tray.setContextMenu(menu); + if (isWindows) { + tray.on("click", () => { + windowManager.ensureMainWindow(); + }); + } + } return tray; } -export function createTrayMenu(windowManager: WindowManager): Menu { +function createTrayMenu(windowManager: WindowManager): Menu { return Menu.buildFromTemplate([ { label: "About Lens", From 4027bbe4617d45dc8766100b9be5a9631f15ba9d Mon Sep 17 00:00:00 2001 From: Alex Andreev Date: Mon, 11 Jan 2021 15:43:13 +0300 Subject: [PATCH 4/9] Getting api by kind when editing an object (#1936) Signed-off-by: Alex Andreev --- src/renderer/api/endpoints/resource-applier.api.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer/api/endpoints/resource-applier.api.ts b/src/renderer/api/endpoints/resource-applier.api.ts index a397cfdda0..9150ae77c5 100644 --- a/src/renderer/api/endpoints/resource-applier.api.ts +++ b/src/renderer/api/endpoints/resource-applier.api.ts @@ -18,7 +18,7 @@ export const resourceApplierApi = { .post("/stack", { data: resource }) .then(data => { const items = data.map(obj => { - const api = apiManager.getApi(obj.metadata.selfLink); + const api = apiManager.getApiByKind(obj.kind, obj.apiVersion); if (api) { return new api.objectConstructor(obj); From 3365cecec213004b016cc939e63dba3f6d021e9e Mon Sep 17 00:00:00 2001 From: Alex Andreev Date: Tue, 12 Jan 2021 09:50:35 +0300 Subject: [PATCH 5/9] Fixing multiline logs wrapping (#1938) Signed-off-by: Alex Andreev --- src/renderer/components/dock/pod-log-list.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer/components/dock/pod-log-list.scss b/src/renderer/components/dock/pod-log-list.scss index 9c14f79fa4..aa0504d255 100644 --- a/src/renderer/components/dock/pod-log-list.scss +++ b/src/renderer/components/dock/pod-log-list.scss @@ -22,7 +22,7 @@ height: 18px; // Must be equal to lineHeight variable in pod-log-list.tsx font-family: $font-monospace; font-size: smaller; - white-space: pre; + white-space: nowrap; &:hover { background: $logRowHoverBackground; From afb68750a2adabdd65ba8c9f6c6e2a3921c0bb14 Mon Sep 17 00:00:00 2001 From: Lauri Nevala Date: Fri, 15 Jan 2021 16:11:41 +0200 Subject: [PATCH 6/9] Prevent initializing clusters multiple times (#1950) * Prevent initializing clusters multiple times Signed-off-by: Lauri Nevala * Do not expose intializing to cluster state Signed-off-by: Lauri Nevala * Convert initializing to observable and ensure it is set to false after init Signed-off-by: Lauri Nevala --- src/main/cluster-manager.ts | 2 +- src/main/cluster.ts | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/cluster-manager.ts b/src/main/cluster-manager.ts index 5717c7278d..1b468e3bb6 100644 --- a/src/main/cluster-manager.ts +++ b/src/main/cluster-manager.ts @@ -14,7 +14,7 @@ export class ClusterManager extends Singleton { // auto-init clusters autorun(() => { clusterStore.enabledClustersList.forEach(cluster => { - if (!cluster.initialized) { + if (!cluster.initialized && !cluster.initializing) { logger.info(`[CLUSTER-MANAGER]: init cluster`, cluster.getMeta()); cluster.init(port); } diff --git a/src/main/cluster.ts b/src/main/cluster.ts index b9ff62e8ac..c6c14f6406 100644 --- a/src/main/cluster.ts +++ b/src/main/cluster.ts @@ -84,6 +84,14 @@ export class Cluster implements ClusterModel, ClusterState { whenInitialized = when(() => this.initialized); whenReady = when(() => this.ready); + /** + * Is cluster object initializinng on-going + * + * @observable + */ + @observable initializing = false; + + /** * Is cluster object initialized * @@ -273,6 +281,7 @@ export class Cluster implements ClusterModel, ClusterState { */ @action async init(port: number) { try { + this.initializing = true; this.contextHandler = new ContextHandler(this); this.kubeconfigManager = await KubeconfigManager.create(this, this.contextHandler, port); this.kubeProxyUrl = `http://localhost:${port}${apiKubePrefix}`; @@ -287,6 +296,8 @@ export class Cluster implements ClusterModel, ClusterState { id: this.id, error: err, }); + } finally { + this.initializing = false; } } From 470b5c52edfc06ae7e7cd9bdea344ac6fe7e992e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 15 Jan 2021 16:12:49 +0200 Subject: [PATCH 7/9] Bump ini from 1.3.5 to 1.3.8 (#1760) Bumps [ini](https://github.com/isaacs/ini) from 1.3.5 to 1.3.8. - [Release notes](https://github.com/isaacs/ini/releases) - [Commits](https://github.com/isaacs/ini/compare/v1.3.5...v1.3.8) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index aba182b040..731e617a3c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7756,9 +7756,9 @@ inherits@2.0.3: integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4= ini@^1.3.4, ini@^1.3.5, ini@~1.3.0: - version "1.3.5" - resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927" - integrity sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw== + version "1.3.8" + resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.8.tgz#a29da425b48806f34767a4efce397269af28432c" + integrity sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew== init-package-json@^1.10.3: version "1.10.3" From b7489e75cb95eeec5fbe1b1a9b3ba64f4b0590fe Mon Sep 17 00:00:00 2001 From: Jari Kolehmainen Date: Tue, 19 Jan 2021 06:30:05 +0200 Subject: [PATCH 8/9] Enable default workspace on first boot (#1965) * enable default workspace on first boot Signed-off-by: Jari Kolehmainen * refactor Signed-off-by: Jari Kolehmainen * use get/set Signed-off-by: Jari Kolehmainen --- src/common/__tests__/workspace-store.test.ts | 7 ++++ src/common/workspace-store.ts | 44 ++++++++++++-------- 2 files changed, 34 insertions(+), 17 deletions(-) diff --git a/src/common/__tests__/workspace-store.test.ts b/src/common/__tests__/workspace-store.test.ts index e69ebda0aa..355eb8b2ce 100644 --- a/src/common/__tests__/workspace-store.test.ts +++ b/src/common/__tests__/workspace-store.test.ts @@ -36,6 +36,13 @@ describe("workspace store tests", () => { expect(ws.getById(WorkspaceStore.defaultId)).not.toBe(null); }); + it("default workspace should be enabled", () => { + const ws = WorkspaceStore.getInstance(); + + expect(ws.workspaces.size).toBe(1); + expect(ws.getById(WorkspaceStore.defaultId).enabled).toBe(true); + }); + it("cannot remove the default workspace", () => { const ws = WorkspaceStore.getInstance(); diff --git a/src/common/workspace-store.ts b/src/common/workspace-store.ts index 7688516af2..921a9126a9 100644 --- a/src/common/workspace-store.ts +++ b/src/common/workspace-store.ts @@ -58,14 +58,7 @@ export class Workspace implements WorkspaceModel, WorkspaceState { * @observable */ @observable ownerRef?: string; - /** - * Is workspace enabled - * - * Workspaces that don't have ownerRef will be enabled by default. Workspaces with ownerRef need to explicitly enable a workspace. - * - * @observable - */ - @observable enabled: boolean; + /** * Last active cluster id * @@ -73,6 +66,9 @@ export class Workspace implements WorkspaceModel, WorkspaceState { */ @observable lastActiveClusterId?: ClusterId; + + @observable private _enabled: boolean; + constructor(data: WorkspaceModel) { Object.assign(this, data); @@ -83,6 +79,21 @@ export class Workspace implements WorkspaceModel, WorkspaceState { } } + /** + * Is workspace enabled + * + * Workspaces that don't have ownerRef will be enabled by default. Workspaces with ownerRef need to explicitly enable a workspace. + * + * @observable + */ + get enabled(): boolean { + return !this.isManaged || this._enabled; + } + + set enabled(enabled: boolean) { + this._enabled = enabled; + } + /** * Is workspace managed by an extension */ @@ -134,10 +145,18 @@ export class WorkspaceStore extends BaseStore { static readonly defaultId: WorkspaceId = "default"; private static stateRequestChannel = "workspace:states"; + @observable currentWorkspaceId = WorkspaceStore.defaultId; + @observable workspaces = observable.map(); + private constructor() { super({ configName: "lens-workspace-store", }); + + this.workspaces.set(WorkspaceStore.defaultId, new Workspace({ + id: WorkspaceStore.defaultId, + name: "default" + })); } async load() { @@ -186,15 +205,6 @@ export class WorkspaceStore extends BaseStore { ipcRenderer.removeAllListeners("workspace:state"); } - @observable currentWorkspaceId = WorkspaceStore.defaultId; - - @observable workspaces = observable.map({ - [WorkspaceStore.defaultId]: new Workspace({ - id: WorkspaceStore.defaultId, - name: "default" - }) - }); - @computed get currentWorkspace(): Workspace { return this.getById(this.currentWorkspaceId); } From dce74fee50314eb0d727ed08484e69d4172974a0 Mon Sep 17 00:00:00 2001 From: Jari Kolehmainen Date: Tue, 19 Jan 2021 07:00:08 +0200 Subject: [PATCH 9/9] v4.0.7 Signed-off-by: Jari Kolehmainen --- package.json | 2 +- static/RELEASE_NOTES.md | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 662a7d9950..3903450bed 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "kontena-lens", "productName": "Lens", "description": "Lens - The Kubernetes IDE", - "version": "4.0.6", + "version": "4.0.7", "main": "static/build/main.js", "copyright": "© 2020, Mirantis, Inc.", "license": "MIT", diff --git a/static/RELEASE_NOTES.md b/static/RELEASE_NOTES.md index 4841690c81..acae9c36c6 100644 --- a/static/RELEASE_NOTES.md +++ b/static/RELEASE_NOTES.md @@ -2,7 +2,17 @@ Here you can find description of changes we've built into each release. While we try our best to make each upgrade automatic and as smooth as possible, there may be some cases where you might need to do something to ensure the application works smoothly. So please read through the release highlights! -## 4.0.6 (current version) +## 4.0.7 (current version) + +- Fix: typo in Prometheus Ingress metrics +- Fix: catch xterm.js fit error +- Fix: Windows tray icon click +- Fix: error on Kubernetes >= 1.20 on object edit +- Fix: multiline log wrapping +- Fix: prevent clusters from initializing multiple times +- Fix: show default workspace on first boot + +## 4.0.6 - Don't open Lens at OS login by default - Disable GPU acceleration by setting an env variable