@@ -92,6 +92,14 @@ type PodProgress =
9292 | { state : 'pending' ; detail ?: string ; pullError ?: string }
9393 | { state : 'failed' ; error : Error }
9494
95+ function isSandboxContainerRunning ( pod : V1Pod ) : boolean {
96+ return Boolean (
97+ pod . status ?. containerStatuses ?. some (
98+ ( status ) => status . name === SANDBOX_CONTAINER_NAME && status . state ?. running
99+ )
100+ )
101+ }
102+
95103/**
96104 * Where a starting pod stands. `failed` when it can no longer become ready: it finished, is being
97105 * deleted, or a container is stuck on a problem no retry fixes. A transient pull failure stays
@@ -137,11 +145,9 @@ function podProgress(pod: V1Pod, kind: SandboxKind): PodProgress {
137145 pullError = `${ waiting . reason } for ${ variable } : ${ message } `
138146 }
139147 }
140- const sandboxRunning = pod . status ?. containerStatuses ?. some (
141- ( status ) => status . name === SANDBOX_CONTAINER_NAME && status . state ?. running
142- )
143148 const baseUrl = agentBaseUrl ( pod )
144- if ( phase === 'Running' && sandboxRunning && baseUrl ) return { state : 'ready' , baseUrl }
149+ if ( phase === 'Running' && isSandboxContainerRunning ( pod ) && baseUrl )
150+ return { state : 'ready' , baseUrl }
145151 const unscheduled = pod . status ?. conditions ?. find (
146152 ( condition ) => condition . type === 'PodScheduled' && condition . status === 'False'
147153 )
@@ -282,8 +288,8 @@ export async function waitUntilReady(
282288 if ( update . status ?. conditions ?. some ( ( c ) => c . type === 'Initialized' && c . status === 'True' ) ) {
283289 mark ( 'initializedMs' )
284290 }
291+ if ( isSandboxContainerRunning ( update ) ) mark ( 'runningMs' )
285292 const progress = podProgress ( update , kind )
286- if ( progress . state === 'ready' ) mark ( 'runningMs' )
287293 if ( progress . state === 'pending' ) {
288294 detail = progress . detail
289295 pullError = progress . pullError ?? pullError
0 commit comments