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.
This commit is contained in:
parent
a0307847b9
commit
a3a8af9a70
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -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]
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user