Merge branch 'allow-to-upgrade-multiple-databases-in-parallel' into 'main'
allow to upgrade multiple databases in parallel See merge request odoo-openupgrade-wizard/odoo-openupgrade-wizard!69
This commit is contained in:
commit
62f77499fb
|
|
@ -0,0 +1,2 @@
|
|||
Add database name to container name and publish Docker ports only when needed
|
||||
to allow to upgrade multiple databases in parallel.
|
||||
|
|
@ -74,6 +74,7 @@ def generate_module_analysis(ctx, step, database, modules):
|
|||
database=initial_database,
|
||||
execution_context="openupgrade",
|
||||
detached_container=True,
|
||||
publish_ports=True,
|
||||
)
|
||||
# INITIAL : install modules to analyse and generate records
|
||||
initial_instance = OdooInstance(ctx, initial_database)
|
||||
|
|
@ -94,7 +95,6 @@ def generate_module_analysis(ctx, step, database, modules):
|
|||
stop_after_init=True,
|
||||
init=get_upgrade_analysis_module(final_step),
|
||||
execution_context="openupgrade",
|
||||
alternative_xml_rpc_port=alternative_xml_rpc_port,
|
||||
)
|
||||
|
||||
# name of the first odoo instance inside the second odoo instance
|
||||
|
|
@ -109,6 +109,7 @@ def generate_module_analysis(ctx, step, database, modules):
|
|||
alternative_xml_rpc_port=alternative_xml_rpc_port,
|
||||
execution_context="openupgrade",
|
||||
links={initial_container.name: odoo_initial_host_name},
|
||||
publish_ports=True,
|
||||
)
|
||||
|
||||
# FINAL : install modules to analyse and generate records
|
||||
|
|
@ -142,5 +143,5 @@ def generate_module_analysis(ctx, step, database, modules):
|
|||
except (KeyboardInterrupt, SystemExit):
|
||||
logger.info("Received Keyboard Interrupt or System Exiting...")
|
||||
finally:
|
||||
kill_odoo(ctx, initial_step)
|
||||
kill_odoo(ctx, final_step)
|
||||
kill_odoo(ctx, initial_database, initial_step)
|
||||
kill_odoo(ctx, final_database, final_step)
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ def install_from_csv(ctx, database, with_demo):
|
|||
detached_container=True,
|
||||
init="base",
|
||||
demo=with_demo,
|
||||
publish_ports=True,
|
||||
)
|
||||
odoo_instance = OdooInstance(ctx, database)
|
||||
odoo_default_company = ctx.obj["config"].get(
|
||||
|
|
@ -79,4 +80,4 @@ def install_from_csv(ctx, database, with_demo):
|
|||
except (KeyboardInterrupt, SystemExit):
|
||||
logger.info("Received Keyboard Interrupt or System Exiting...")
|
||||
finally:
|
||||
kill_odoo(ctx, migration_step)
|
||||
kill_odoo(ctx, database, migration_step)
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ def run(
|
|||
stop_after_init=stop_after_init,
|
||||
demo=with_demo,
|
||||
execution_context=execution_context,
|
||||
publish_ports=True,
|
||||
)
|
||||
if not stop_after_init:
|
||||
logger.info(
|
||||
|
|
@ -77,4 +78,4 @@ def run(
|
|||
except (KeyboardInterrupt, SystemExit):
|
||||
logger.info("Received Keyboard Interrupt or System Exiting...")
|
||||
finally:
|
||||
kill_odoo(ctx, migration_step)
|
||||
kill_odoo(ctx, database, migration_step)
|
||||
|
|
|
|||
|
|
@ -43,5 +43,5 @@ def upgrade(ctx, first_step, last_step, database, with_demo):
|
|||
except (KeyboardInterrupt, SystemExit):
|
||||
logger.info("Received Keyboard Interrupt or System Exiting...")
|
||||
finally:
|
||||
kill_odoo(ctx, migration_step)
|
||||
kill_odoo(ctx, database, migration_step)
|
||||
execute_click_odoo_python_files(ctx, database, migration_step)
|
||||
|
|
|
|||
|
|
@ -124,10 +124,7 @@ def kill_container(container_name):
|
|||
)
|
||||
try:
|
||||
container.stop()
|
||||
container.wait()
|
||||
container.remove()
|
||||
except docker.errors.NotFound as err:
|
||||
logger.debug(f"Cannot kill container {container.name}: {err}")
|
||||
|
||||
# TODO, we should here filter by name
|
||||
# but filters={"name": container_name}
|
||||
# doesn't work...
|
||||
client.containers.prune()
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ from odoo_openupgrade_wizard.tools.tools_docker import (
|
|||
from odoo_openupgrade_wizard.tools.tools_postgres import get_postgres_container
|
||||
from odoo_openupgrade_wizard.tools.tools_system import get_script_folder
|
||||
|
||||
DEFAULT_ODOO_HTTP_PORT = 8069
|
||||
|
||||
|
||||
def get_repo_file_path(ctx, odoo_version: float) -> Path:
|
||||
"""return the relative path of the repos.yml file
|
||||
|
|
@ -107,13 +109,15 @@ def get_docker_image_tag(ctx, odoo_version: float) -> str:
|
|||
)
|
||||
|
||||
|
||||
def get_docker_container_name(ctx, migration_step: dict) -> str:
|
||||
"""Return a docker container name, based on project name,
|
||||
def get_docker_container_name(ctx, database: str, migration_step: dict) -> str:
|
||||
"""Return a docker container name, based on project name, database name,
|
||||
odoo version and migration step"""
|
||||
return "odoo-openupgrade-wizard-container__%s__%s__step-%s" % (
|
||||
ctx.obj["config"]["project_name"],
|
||||
str(migration_step["version"]).rjust(4, "0"),
|
||||
str(migration_step["name"]).rjust(2, "0"),
|
||||
return "oow-{project}-{database}-{version}-step-{step}".format(
|
||||
project=ctx.obj["config"]["project_name"],
|
||||
database=database,
|
||||
# FIXME: version should be a string, but it is a float
|
||||
version=str(migration_step["version"]).rjust(4, "0"),
|
||||
step=str(migration_step["name"]).rjust(2, "0"),
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -215,6 +219,7 @@ def run_odoo(
|
|||
execution_context: str = False,
|
||||
alternative_xml_rpc_port: int = False,
|
||||
links: dict = {},
|
||||
publish_ports: bool = False,
|
||||
):
|
||||
# Ensure that Postgres container exist
|
||||
get_postgres_container(ctx)
|
||||
|
|
@ -254,6 +259,7 @@ def run_odoo(
|
|||
execution_context=execution_context,
|
||||
alternative_xml_rpc_port=alternative_xml_rpc_port,
|
||||
links=links,
|
||||
publish_ports=publish_ports,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -266,6 +272,7 @@ def run_container_odoo(
|
|||
alternative_xml_rpc_port: int = False,
|
||||
execution_context: str = False,
|
||||
links: dict = {},
|
||||
publish_ports: bool = False,
|
||||
):
|
||||
env_path = ctx.obj["env_folder_path"]
|
||||
odoo_env_path = get_odoo_env_path(ctx, migration_step["version"])
|
||||
|
|
@ -278,13 +285,16 @@ def run_container_odoo(
|
|||
|
||||
links.update({ctx.obj["config"]["postgres_container_name"]: "db"})
|
||||
|
||||
if publish_ports:
|
||||
ports = {host_xmlrpc_port: DEFAULT_ODOO_HTTP_PORT}
|
||||
else:
|
||||
ports = {}
|
||||
|
||||
return run_container(
|
||||
get_docker_image_tag(ctx, migration_step["version"]),
|
||||
get_docker_container_name(ctx, migration_step),
|
||||
get_docker_container_name(ctx, database, migration_step),
|
||||
command=command,
|
||||
ports={
|
||||
host_xmlrpc_port: 8069,
|
||||
},
|
||||
ports=ports,
|
||||
volumes={
|
||||
env_path: "/env/",
|
||||
odoo_env_path: "/odoo_env/",
|
||||
|
|
@ -295,8 +305,8 @@ def run_container_odoo(
|
|||
)
|
||||
|
||||
|
||||
def kill_odoo(ctx, migration_step: dict):
|
||||
kill_container(get_docker_container_name(ctx, migration_step))
|
||||
def kill_odoo(ctx, database, migration_step: dict):
|
||||
kill_container(get_docker_container_name(ctx, database, migration_step))
|
||||
|
||||
|
||||
def execute_click_odoo_python_files(
|
||||
|
|
@ -351,7 +361,7 @@ def execute_click_odoo_python_files(
|
|||
)
|
||||
raise e
|
||||
finally:
|
||||
kill_odoo(ctx, migration_step)
|
||||
kill_odoo(ctx, database, migration_step)
|
||||
|
||||
|
||||
def get_odoo_modules_from_csv(module_file_path: Path) -> list:
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user