mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fat fingers
Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
This commit is contained in:
parent
872e9dec7f
commit
5de48c4eaf
@ -35,25 +35,11 @@ import type { IKubeWatchEvent } from "./kube-watch-api";
|
|||||||
import { KubeJsonApi, KubeJsonApiData } from "./kube-json-api";
|
import { KubeJsonApi, KubeJsonApiData } from "./kube-json-api";
|
||||||
import { noop } from "../utils";
|
import { noop } from "../utils";
|
||||||
import type { RequestInit } from "node-fetch";
|
import type { RequestInit } from "node-fetch";
|
||||||
import AbortController from "abort-controller";
|
import { AbortController } from "node-abort-controller";
|
||||||
import { Agent, AgentOptions } from "https";
|
import { Agent, AgentOptions } from "https";
|
||||||
import type { Patch } from "rfc6902";
|
import type { Patch } from "rfc6902";
|
||||||
import electron from "electron";
|
import electron from "electron";
|
||||||
|
|
||||||
const onceSystemResume = () =>
|
|
||||||
new Promise(resolve => {
|
|
||||||
electron.powerMonitor.once("resume", () => {
|
|
||||||
resolve(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
const onceSystemSuspend = () =>
|
|
||||||
new Promise(resolve => {
|
|
||||||
electron.powerMonitor.once("suspend", () => {
|
|
||||||
resolve(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
export interface IKubeApiOptions<T extends KubeObject> {
|
export interface IKubeApiOptions<T extends KubeObject> {
|
||||||
/**
|
/**
|
||||||
* base api-path for listing all resources, e.g. "/api/v1/pods"
|
* base api-path for listing all resources, e.g. "/api/v1/pods"
|
||||||
@ -575,8 +561,7 @@ export class KubeApi<T extends KubeObject> {
|
|||||||
this.watchSystemStatus();
|
this.watchSystemStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
onceSystemSuspend().then(async (suspended) => {
|
electron.powerMonitor.once("suspend", () => {
|
||||||
if (suspended) {
|
|
||||||
logger.info(`[KUBE-API] system suspended, abort watching of ${watchUrl}...`);
|
logger.info(`[KUBE-API] system suspended, abort watching of ${watchUrl}...`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -584,9 +569,7 @@ export class KubeApi<T extends KubeObject> {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(`[KUBE-API] error aborting watch (${watchId})`, error);
|
logger.error(`[KUBE-API] error aborting watch (${watchId})`, error);
|
||||||
}
|
}
|
||||||
const resumed = await onceSystemResume();
|
electron.powerMonitor.once("resume", () => {
|
||||||
|
|
||||||
if (resumed) {
|
|
||||||
clearTimeout(timedRetry);
|
clearTimeout(timedRetry);
|
||||||
logger.info(`[KUBE-API] system resumed, resume watching of ${watchUrl}...`);
|
logger.info(`[KUBE-API] system resumed, resume watching of ${watchUrl}...`);
|
||||||
timedRetry = setTimeout(() => {
|
timedRetry = setTimeout(() => {
|
||||||
@ -594,8 +577,7 @@ export class KubeApi<T extends KubeObject> {
|
|||||||
// 3000 is a naive value, we assume that after 3 seconds the system is ready
|
// 3000 is a naive value, we assume that after 3 seconds the system is ready
|
||||||
// to start watching again. (Network interface/DNS is ready etc.)
|
// to start watching again. (Network interface/DNS is ready etc.)
|
||||||
}, 3000);
|
}, 3000);
|
||||||
}
|
});
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
responsePromise
|
responsePromise
|
||||||
@ -613,7 +595,7 @@ export class KubeApi<T extends KubeObject> {
|
|||||||
|
|
||||||
if (this.systemSuspended) {
|
if (this.systemSuspended) {
|
||||||
// don't retry if got "end", "close", "error" and system is suspended
|
// don't retry if got "end", "close", "error" and system is suspended
|
||||||
// instead, wait for system resume and resume watch using onceSystemResume();
|
// instead, wait for system resume and resume watch using electron.powerMonitor.once;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -30,7 +30,7 @@ import { ensureObjectSelfLink, IKubeApiQueryParams, KubeApi } from "./kube-api";
|
|||||||
import { parseKubeApi } from "./kube-api-parse";
|
import { parseKubeApi } from "./kube-api-parse";
|
||||||
import type { KubeJsonApiData } from "./kube-json-api";
|
import type { KubeJsonApiData } from "./kube-json-api";
|
||||||
import type { RequestInit } from "node-fetch";
|
import type { RequestInit } from "node-fetch";
|
||||||
import { AbortController } from "node-abort-controller";
|
import AbortController from "abort-controller";
|
||||||
import type { Patch } from "rfc6902";
|
import type { Patch } from "rfc6902";
|
||||||
|
|
||||||
export interface KubeObjectStoreLoadingParams<K extends KubeObject> {
|
export interface KubeObjectStoreLoadingParams<K extends KubeObject> {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user