added backoff if NotFound on getPodPhase

This commit is contained in:
Nikola Jokic
2022-10-04 15:14:48 +02:00
parent 79262ba5fb
commit 66566368e0
2 changed files with 9 additions and 3 deletions

View File

@@ -322,13 +322,18 @@ export async function waitForPodPhases(
const backOffManager = new BackOffManager(maxTimeSeconds) const backOffManager = new BackOffManager(maxTimeSeconds)
let phase: PodPhase = PodPhase.UNKNOWN let phase: PodPhase = PodPhase.UNKNOWN
try { try {
while (true) { let retryCount = 0
while (retryCount < 3) {
try { try {
phase = await getPodPhase(podName) phase = await getPodPhase(podName)
} catch (err) { } catch (err) {
const e = err as k8s.HttpError const e = err as k8s.HttpError
if (e?.body?.reason === 'NotFound') { if (e?.body?.reason === 'NotFound') {
phase = PodPhase.UNKNOWN retryCount++
await backOffManager.backOff()
continue
} else {
throw err
} }
} }
if (awaitingPhases.has(phase)) { if (awaitingPhases.has(phase)) {
@@ -342,6 +347,7 @@ export async function waitForPodPhases(
} }
await backOffManager.backOff() await backOffManager.backOff()
} }
throw new Error(`Failed to get pod phase after ${retryCount} attempts`)
} catch (error) { } catch (error) {
throw new Error(`Pod ${podName} is unhealthy with phase status ${phase}`) throw new Error(`Pod ${podName} is unhealthy with phase status ${phase}`)
} }

View File

@@ -231,7 +231,7 @@ export class TestHelper {
await waitForPodPhases( await waitForPodPhases(
`${registryName}-0`, `${registryName}-0`,
new Set([PodPhase.RUNNING]), new Set([PodPhase.RUNNING]),
new Set([PodPhase.PENDING, PodPhase.UNKNOWN]) new Set([PodPhase.PENDING])
) )
await k8sApi.createNamespacedService(namespace, svc) await k8sApi.createNamespacedService(namespace, svc)
return { return {