Merge branch 'fix-docker_kill_error_not_found' into 'main'
Fix docker kill error not found and pre-migration files (fix #15 #16) Closes #16 and #15 See merge request odoo-openupgrade-wizard/odoo-openupgrade-wizard!28
This commit is contained in:
commit
a55b921457
|
|
@ -12,6 +12,9 @@ from odoo_openupgrade_wizard.tools.tools_odoo import (
|
|||
kill_odoo,
|
||||
run_odoo,
|
||||
)
|
||||
from odoo_openupgrade_wizard.tools.tools_postgres import (
|
||||
execute_sql_files_pre_migration,
|
||||
)
|
||||
|
||||
|
||||
@click.command()
|
||||
|
|
@ -25,6 +28,7 @@ def upgrade(ctx, first_step, last_step, database):
|
|||
ctx, first_step, last_step
|
||||
)
|
||||
for migration_step in migration_steps:
|
||||
execute_sql_files_pre_migration(ctx, database, migration_step)
|
||||
try:
|
||||
run_odoo(
|
||||
ctx,
|
||||
|
|
|
|||
|
|
@ -114,17 +114,28 @@ def exec_container(container, command):
|
|||
|
||||
def kill_container(container_name):
|
||||
client = get_docker_client()
|
||||
containers = client.containers.list(
|
||||
all=True,
|
||||
filters={"name": container_name},
|
||||
)
|
||||
|
||||
try:
|
||||
containers = client.containers.list(
|
||||
all=True,
|
||||
filters={"name": container_name},
|
||||
)
|
||||
except docker.errors.NotFound as err:
|
||||
logger.debug(f"Cannot kill container {container_name}: " + str(err))
|
||||
containers = []
|
||||
|
||||
for container in containers:
|
||||
if container.status != "exited":
|
||||
logger.debug(
|
||||
"Stop container %s, based on image '%s'."
|
||||
% (container.name, ",".join(container.image.tags))
|
||||
)
|
||||
container.stop()
|
||||
try:
|
||||
container.stop()
|
||||
except docker.errors.NotFound as err:
|
||||
logger.debug(
|
||||
f"Cannot kill container {container.name}: " + str(err)
|
||||
)
|
||||
|
||||
# TODO, we should here filter by name
|
||||
# but filters={"name": container_name}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user