@@ -14,6 +14,10 @@ def die(message: str) -> None:
14
14
sys .exit (1 )
15
15
16
16
17
+ def print_remote_result (result : Result ) -> None :
18
+ print (str (result ))
19
+
20
+
17
21
def mask_credentials (env_vars : Dict [str , Any ]) -> Dict [str , Any ]:
18
22
masked_env_vars = env_vars .copy ()
19
23
# Only mask if vars exist
@@ -249,12 +253,7 @@ def get_docker_image(remote_host: Host) -> str:
249
253
)
250
254
images = [line .strip () for line in result .stdout .splitlines () if "SNAPSHOT" in line ]
251
255
if len (images ) != 1 :
252
- die (
253
- "❌ Error in finding observe-agent image, command output:\n {}\n command error:\n {}" .format (
254
- result .stdout or "<empty>" ,
255
- result .stderr or "<empty>" ,
256
- )
257
- )
256
+ die ("❌ Error in finding observe-agent image\n " + str (result ))
258
257
259
258
return images [0 ]
260
259
@@ -288,6 +287,22 @@ def get_docker_container(remote_host: Host, retries: int = 3) -> str:
288
287
)
289
288
time .sleep (1 )
290
289
return get_docker_container (remote_host , retries - 1 )
290
+ elif retries == 0 :
291
+ # No retries left, see if we can get logs from stopped containers to help debug.
292
+ result = remote_host .run_command ('sudo docker ps --format "{{.ID}}"' )
293
+ if result .stdout != "" :
294
+ container_ids = result .stdout .splitlines ()
295
+ for container_id in container_ids :
296
+ print (
297
+ "Logs for container {}:" .format (container_id ),
298
+ file = sys .stderr ,
299
+ )
300
+ result = remote_host .run_command (
301
+ "sudo docker logs {}" .format (container_id )
302
+ )
303
+ print_remote_result (result )
304
+ else :
305
+ print_remote_result (result )
291
306
die (
292
307
"❌ Error in finding observe-agent container; command output:\n {}\n command error:\n {}" .format (
293
308
result .stdout or "<empty>" ,
0 commit comments