diff options
| author | Christophe Monniez <moc@odoo.com> | 2020-08-20 12:32:27 +0000 |
|---|---|---|
| committer | Christophe Monniez <moc@odoo.com> | 2020-08-21 08:59:25 +0000 |
| commit | 5dbabad0a168efb19ef4f39aac4464034f5bcb0a (patch) | |
| tree | 89ba893691c71a0269eb2a2de2cf3a00cf923d86 /setup | |
| parent | c7c6ac47f8f3172c9eee03754f5483ec95083f17 (diff) | |
[FIX] packaging: stop docker container when odoo fails
When the Odoo installation is tested, if the test fails an error is
raised but the Docker container is not stopped.
As a result, a ghost container stays alive with a Postgres server
running. Worse, if another package is built on the same host, the
ghost container prevent the other build to succeed.
With this commit, a specific Exception is raised and the container is
stopped in any case.
closes odoo/odoo#56270
X-original-commit: fbe2092d37af02276a49e335538d8caff3a15e7d
Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
Diffstat (limited to 'setup')
| -rwxr-xr-x | setup/package.py | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/setup/package.py b/setup/package.py index 18bc5559a9b..b21768d8abe 100755 --- a/setup/package.py +++ b/setup/package.py @@ -40,6 +40,14 @@ USER odoo """ % {'group_id': os.getgid(), 'user_id': os.getuid()} +class OdooTestTimeoutError(Exception): + pass + + +class OdooTestError(Exception): + pass + + def run_cmd(cmd, chdir=None, timeout=None): logging.info("Running command %s", cmd) return subprocess.run(cmd, cwd=chdir, timeout=timeout) @@ -60,12 +68,12 @@ def _rpc_count_modules(addr='http://127.0.0.1', port=8069, dbname='mycompany'): ) if toinstallmodules: logging.error("Package test: FAILED. Not able to install dependencies of base.") - raise Exception("Installation of package failed") + raise OdooTestError("Installation of package failed") else: logging.info("Package test: successfuly installed %s modules" % len(modules)) else: logging.error("Package test: FAILED. Not able to install base.") - raise Exception("Package test: FAILED. Not able to install base.") + raise OdooTestError("Package test: FAILED. Not able to install base.") def publish(args, pub_type, extensions): @@ -184,14 +192,6 @@ def _prepare_build_dir(args, win32=False): # Docker stuffs -class OdooTestTimeoutError(Exception): - pass - - -class OdooTestError(Exception): - pass - - class Docker(): """Base Docker class. Must be inherited by specific Docker builder class""" arch = None @@ -265,8 +265,10 @@ class Docker(): while self.is_running() and (time.time() - start_time) < INSTALL_TIMEOUT: time.sleep(5) if os.path.exists(os.path.join(args.build_dir, 'odoo.pid')): - _rpc_count_modules(port=self.exposed_port) - self.stop() + try: + _rpc_count_modules(port=self.exposed_port) + finally: + self.stop() return if self.is_running(): self.stop() |
