From 386da7e894aa92f9a6c0f73dc560698e7ab0e49f Mon Sep 17 00:00:00 2001 From: David Kwon Date: Thu, 18 Jul 2024 09:33:32 -0400 Subject: [PATCH] fix: allow multiple pod matches for DWO webhook pods (#2895) Signed-off-by: admin --- src/api/kube-client.ts | 8 ++++---- src/tasks/installers/dev-workspace/dev-workspace-tasks.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/api/kube-client.ts b/src/api/kube-client.ts index 9dc0a63f4..14f0960da 100644 --- a/src/api/kube-client.ts +++ b/src/api/kube-client.ts @@ -745,7 +745,7 @@ export class KubeClient { return conditions } - async getPodReadyConditionStatus(selector: string, namespace: string): Promise { + async getPodReadyConditionStatus(selector: string, namespace: string, allowMultiple: boolean): Promise { const k8sCoreApi = this.kubeConfig.makeApiClient(CoreV1Api) let res try { @@ -763,7 +763,7 @@ export class KubeClient { return 'False' } - if (res.body.items.length > 1) { + if (!allowMultiple && res.body.items.length > 1) { // Several pods found, rolling update? return } @@ -780,10 +780,10 @@ export class KubeClient { } } - async waitForPodReady(selector: string, namespace: string, intervalMs = 500, timeoutMs = this.podReadyTimeout) { + async waitForPodReady(selector: string, namespace: string, allowMultiple = false, intervalMs = 500, timeoutMs = this.podReadyTimeout) { const iterations = timeoutMs / intervalMs for (let index = 0; index < iterations; index++) { - const readyStatus = await this.getPodReadyConditionStatus(selector, namespace) + const readyStatus = await this.getPodReadyConditionStatus(selector, namespace, allowMultiple) if (readyStatus === 'True') { return } diff --git a/src/tasks/installers/dev-workspace/dev-workspace-tasks.ts b/src/tasks/installers/dev-workspace/dev-workspace-tasks.ts index 1c2e0ae83..07f158334 100644 --- a/src/tasks/installers/dev-workspace/dev-workspace-tasks.ts +++ b/src/tasks/installers/dev-workspace/dev-workspace-tasks.ts @@ -133,7 +133,7 @@ export namespace DevWorkspacesTasks { task: async (ctx: any, task: any) => { const kubeHelper = KubeClient.getInstance() await kubeHelper.waitForPodReady('app.kubernetes.io/name=devworkspace-controller', ctx[DevWorkspaceContext.NAMESPACE]) - await kubeHelper.waitForPodReady('app.kubernetes.io/name=devworkspace-webhook-server', ctx[DevWorkspaceContext.NAMESPACE]) + await kubeHelper.waitForPodReady('app.kubernetes.io/name=devworkspace-webhook-server', ctx[DevWorkspaceContext.NAMESPACE], true) task.title = `${task.title}...[OK]` }, }