File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -304,10 +304,22 @@ func (o *DebugOptions) getContainerIdByName(pod *corev1.Pod, containerName strin
304304 continue
305305 }
306306 if ! containerStatus .Ready {
307- return "" , fmt .Errorf ("container %s id not ready" , containerName )
307+ return "" , fmt .Errorf ("container [%s] not ready" , containerName )
308308 }
309309 return containerStatus .ContainerID , nil
310310 }
311+
312+ // #14 otherwise we should search for running init containers
313+ for _ , initContainerStatus := range pod .Status .InitContainerStatuses {
314+ if initContainerStatus .Name != containerName {
315+ continue
316+ }
317+ if initContainerStatus .State .Running == nil {
318+ return "" , fmt .Errorf ("init container [%s] is not running" , containerName )
319+ }
320+ return initContainerStatus .ContainerID , nil
321+ }
322+
311323 return "" , fmt .Errorf ("cannot find specified container %s" , containerName )
312324}
313325
You can’t perform that action at this time.
0 commit comments