Skip to content

Commit

Permalink
fix: allow multiple pod matches for DWO webhook pods (#2895)
Browse files Browse the repository at this point in the history
Signed-off-by: admin <[email protected]>
  • Loading branch information
dkwon17 committed Jul 18, 2024
1 parent 8e77812 commit 386da7e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/api/kube-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ export class KubeClient {
return conditions
}

async getPodReadyConditionStatus(selector: string, namespace: string): Promise<string | undefined> {
async getPodReadyConditionStatus(selector: string, namespace: string, allowMultiple: boolean): Promise<string | undefined> {
const k8sCoreApi = this.kubeConfig.makeApiClient(CoreV1Api)
let res
try {
Expand All @@ -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
}
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion src/tasks/installers/dev-workspace/dev-workspace-tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]`
},
}
Expand Down

0 comments on commit 386da7e

Please sign in to comment.