File tree 1 file changed +13
-1
lines changed 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -304,10 +304,22 @@ func (o *DebugOptions) getContainerIdByName(pod *corev1.Pod, containerName strin
304
304
continue
305
305
}
306
306
if ! containerStatus .Ready {
307
- return "" , fmt .Errorf ("container %s id not ready" , containerName )
307
+ return "" , fmt .Errorf ("container [%s] not ready" , containerName )
308
308
}
309
309
return containerStatus .ContainerID , nil
310
310
}
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
+
311
323
return "" , fmt .Errorf ("cannot find specified container %s" , containerName )
312
324
}
313
325
You can’t perform that action at this time.
0 commit comments