From a3a8af9a70b283f8e64219bf82d4924b94e05780 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Taymans?= Date: Thu, 9 Nov 2023 16:27:29 +0100 Subject: [PATCH] Fix listing containers during removal of containers Removing a container can take some time to be performed. Listing containers when a container is currently being removed may cause errors. Because listing container and filtering them by name requires to fetch data from the container that is currently being removed. --- odoo_openupgrade_wizard/tools/tools_docker.py | 1 + odoo_openupgrade_wizard/tools/tools_postgres.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/odoo_openupgrade_wizard/tools/tools_docker.py b/odoo_openupgrade_wizard/tools/tools_docker.py index ce73a8c..0223a4a 100644 --- a/odoo_openupgrade_wizard/tools/tools_docker.py +++ b/odoo_openupgrade_wizard/tools/tools_docker.py @@ -130,6 +130,7 @@ def kill_container(container_name): containers = client.containers.list( all=True, filters={"name": container_name}, + ignore_removed=True, ) except docker.errors.NotFound as err: logger.debug(f"Cannot kill container {container_name}: " + str(err)) diff --git a/odoo_openupgrade_wizard/tools/tools_postgres.py b/odoo_openupgrade_wizard/tools/tools_postgres.py index 1e108ea..cfe95d1 100644 --- a/odoo_openupgrade_wizard/tools/tools_postgres.py +++ b/odoo_openupgrade_wizard/tools/tools_postgres.py @@ -21,7 +21,9 @@ def get_postgres_container(ctx): # Check if container exists containers = client.containers.list( - all=True, filters={"name": container_name} + all=True, + filters={"name": container_name}, + ignore_removed=True, ) if containers: container = containers[0]