mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
review fixes
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
parent
45aa08d396
commit
e7943ce05f
@ -381,9 +381,7 @@ export class KubeApi<T extends KubeObject = any> {
|
|||||||
|
|
||||||
responsePromise.then((response) => {
|
responsePromise.then((response) => {
|
||||||
if (!response.ok && !abortController.signal.aborted) {
|
if (!response.ok && !abortController.signal.aborted) {
|
||||||
if (callback) {
|
callback?.(null, response);
|
||||||
callback(null, response);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -424,19 +422,13 @@ export class KubeApi<T extends KubeObject = any> {
|
|||||||
}, (error) => {
|
}, (error) => {
|
||||||
if (error instanceof DOMException) return; // AbortController rejects, we can ignore it
|
if (error instanceof DOMException) return; // AbortController rejects, we can ignore it
|
||||||
|
|
||||||
if (callback) {
|
callback?.(null, error);
|
||||||
callback(null, error);
|
|
||||||
}
|
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
if (callback) {
|
callback?.(null, error);
|
||||||
callback(null, error);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const disposer = () => {
|
const disposer = () => {
|
||||||
if (!abortController.signal.aborted) {
|
abortController.abort();
|
||||||
abortController.abort();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return disposer;
|
return disposer;
|
||||||
|
|||||||
@ -48,8 +48,8 @@ export interface IKubeStatus {
|
|||||||
reason?: string;
|
reason?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class KubeStatus implements IKubeStatus {
|
export class KubeStatus {
|
||||||
public readonly kind: string;
|
public readonly kind = "Status";
|
||||||
public readonly apiVersion: string;
|
public readonly apiVersion: string;
|
||||||
public readonly code: number;
|
public readonly code: number;
|
||||||
public readonly message: string;
|
public readonly message: string;
|
||||||
|
|||||||
@ -288,6 +288,9 @@ export abstract class KubeObjectStore<T extends KubeObject = any> extends ItemSt
|
|||||||
}
|
}
|
||||||
|
|
||||||
private watchNamespace(api: KubeApi<T>, namespace: string, abortController: AbortController) {
|
private watchNamespace(api: KubeApi<T>, namespace: string, abortController: AbortController) {
|
||||||
|
let timedRetry: NodeJS.Timeout;
|
||||||
|
|
||||||
|
abortController.signal.addEventListener("abort", () => clearTimeout(timedRetry));
|
||||||
|
|
||||||
const callback = (data: IKubeWatchEvent, error: any) => {
|
const callback = (data: IKubeWatchEvent, error: any) => {
|
||||||
if (!this.isLoaded || abortController.signal.aborted) return;
|
if (!this.isLoaded || abortController.signal.aborted) return;
|
||||||
@ -297,9 +300,7 @@ export abstract class KubeObjectStore<T extends KubeObject = any> extends ItemSt
|
|||||||
// api has gone, let's not retry
|
// api has gone, let's not retry
|
||||||
return;
|
return;
|
||||||
} else { // not sure what to do, best to retry
|
} else { // not sure what to do, best to retry
|
||||||
setTimeout(() => {
|
timedRetry = setTimeout(() => {
|
||||||
if (abortController.signal.aborted) return;
|
|
||||||
|
|
||||||
api.watch({
|
api.watch({
|
||||||
namespace,
|
namespace,
|
||||||
abortController,
|
abortController,
|
||||||
@ -309,9 +310,7 @@ export abstract class KubeObjectStore<T extends KubeObject = any> extends ItemSt
|
|||||||
}
|
}
|
||||||
} else if (error instanceof KubeStatus && error.code === 410) {
|
} else if (error instanceof KubeStatus && error.code === 410) {
|
||||||
// resourceVersion has gone, let's try to reload
|
// resourceVersion has gone, let's try to reload
|
||||||
setTimeout(() => {
|
timedRetry = setTimeout(() => {
|
||||||
if (abortController.signal.aborted) return;
|
|
||||||
|
|
||||||
(namespace === "" ? this.loadAll({ merge: false }) : this.loadAll({namespaces: [namespace]})).then(() => {
|
(namespace === "" ? this.loadAll({ merge: false }) : this.loadAll({namespaces: [namespace]})).then(() => {
|
||||||
api.watch({
|
api.watch({
|
||||||
namespace,
|
namespace,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user