Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow wait for multiple DWO webhook pods #2895

Merged
merged 1 commit into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Loading