From 75c25e2d32e2588ad3a7068a8494844743ed8b62 Mon Sep 17 00:00:00 2001 From: liuh-80 Date: Mon, 20 May 2024 02:36:09 +0000 Subject: [PATCH 1/2] Fix docker-wait-any script crash issue --- files/image_config/misc/docker-wait-any | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/files/image_config/misc/docker-wait-any b/files/image_config/misc/docker-wait-any index f4001d7e02c5..49097ca4c03a 100755 --- a/files/image_config/misc/docker-wait-any +++ b/files/image_config/misc/docker-wait-any @@ -49,8 +49,15 @@ def wait_for_container(docker_client, container_name): log.log_info("Waiting on container '{}'".format(container_name)) while True: - docker_client.wait(container_name) - + try: + docker_client.wait(container_name) + except TypeError as e: + if g_thread_exit_event.is_set(): + # When other thread exist, main thread will exit and docker_client will be destoryed + log.log_info("Container {} wait thread get exception: {}".format(container_name, e)) + else: + raise e + log.log_info("No longer waiting on container '{}'".format(container_name)) # If this is a dependent service and warm restart is enabled for the system/container, From 5c0a3a77be34b8506846c74cc92192edadf916d9 Mon Sep 17 00:00:00 2001 From: liuh-80 Date: Mon, 20 May 2024 02:43:55 +0000 Subject: [PATCH 2/2] Improve code --- files/image_config/misc/docker-wait-any | 1 + 1 file changed, 1 insertion(+) diff --git a/files/image_config/misc/docker-wait-any b/files/image_config/misc/docker-wait-any index 49097ca4c03a..a76efc0d8c16 100755 --- a/files/image_config/misc/docker-wait-any +++ b/files/image_config/misc/docker-wait-any @@ -55,6 +55,7 @@ def wait_for_container(docker_client, container_name): if g_thread_exit_event.is_set(): # When other thread exist, main thread will exit and docker_client will be destoryed log.log_info("Container {} wait thread get exception: {}".format(container_name, e)) + return else: raise e