mirror of
https://github.com/actions/runner-container-hooks.git
synced 2025-12-17 02:06:43 +00:00
added backoff if NotFound on getPodPhase
This commit is contained in:
@@ -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}`)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user