File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -96,7 +96,7 @@ def _run_from_pod(self, cmd):
96
96
return error , stdout , stderr
97
97
except Exception as e :
98
98
self .module .fail_json (
99
- msg = "Error while running/parsing from pod {1 }/{2 } command='{0 }' : {3}" .format (
99
+ msg = "Error while running/parsing from pod {0 }/{1 } command='{2 }' : {3}" .format (
100
100
self .namespace , self .name , cmd , to_native (e )
101
101
)
102
102
)
@@ -435,11 +435,13 @@ def _fail(exc):
435
435
436
436
try :
437
437
result = svc .client .get (resource , name = name , namespace = namespace )
438
- containers = [
439
- c ["name" ] for c in result .to_dict ()[ "status" ][ "containerStatuses" ]
440
- ]
441
- if container and container not in containers :
438
+ containers = dict ({
439
+ c ["name" ]: c for cl in [ 'initContainerStatuses' , 'containerStatuses' ] for c in result .to_dict (). get ( "status" ). get ( cl , [])
440
+ })
441
+ if container and container not in containers . keys () :
442
442
module .fail_json (msg = "Pod has no container {0}" .format (container ))
443
- return containers
443
+ if container and container in containers and not bool (containers [container ]['started' ]):
444
+ module .fail_json (msg = "Pod container {0} is not started" .format (container ))
445
+ return containers .keys ()
444
446
except Exception as exc :
445
447
_fail (exc )
You can’t perform that action at this time.
0 commit comments