diff --git a/swh/vault/api/server.py b/swh/vault/api/server.py --- a/swh/vault/api/server.py +++ b/swh/vault/api/server.py @@ -74,14 +74,7 @@ vcfg.update(vcfg.get("args", {})) # Default to top-level value if any - if "cache" not in vcfg: - vcfg["cache"] = cfg.get("cache") - if "storage" not in vcfg: - vcfg["storage"] = cfg.get("storage") - if "scheduler" not in vcfg: - vcfg["scheduler"] = cfg.get("scheduler") - if "client_max_size" not in vcfg: - vcfg["client_max_size"] = cfg.get("client_max_size") + vcfg = {**cfg, **vcfg} for key in ("cache", "storage", "scheduler"): if not vcfg.get(key): diff --git a/swh/vault/backend.py b/swh/vault/backend.py --- a/swh/vault/backend.py +++ b/swh/vault/backend.py @@ -73,7 +73,7 @@ self.cache = VaultCache(**config["cache"]) self.scheduler = get_scheduler(**config["scheduler"]) self.storage = get_storage(**config["storage"]) - self.smtp_server = smtplib.SMTP() + self.smtp_server = smtplib.SMTP(**config.get("smtp", {})) db_conn = config["db"] self._pool = psycopg2.pool.ThreadedConnectionPool( diff --git a/swh/vault/cookers/base.py b/swh/vault/cookers/base.py --- a/swh/vault/cookers/base.py +++ b/swh/vault/cookers/base.py @@ -6,6 +6,7 @@ import abc import io import logging +import traceback from typing import ClassVar, Set from psycopg2.extensions import QueryCanceledError @@ -141,10 +142,12 @@ self.backend.set_progress(self.BUNDLE_TYPE, self.swhid, str(e)) except Exception: self.backend.set_status(self.BUNDLE_TYPE, self.swhid, "failed") + tb = traceback.format_exc() self.backend.set_progress( self.BUNDLE_TYPE, self.swhid, - "Internal Server Error. This incident will be reported.", + f"Internal Server Error. This incident will be reported.\n" + f"The full error was:\n\n{tb}", ) logging.exception("Bundle cooking failed.") else: diff --git a/swh/vault/tests/test_cookers_base.py b/swh/vault/tests/test_cookers_base.py --- a/swh/vault/tests/test_cookers_base.py +++ b/swh/vault/tests/test_cookers_base.py @@ -1,8 +1,9 @@ -# Copyright (C) 2018 The Software Heritage developers +# Copyright (C) 2018-2021 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information +import textwrap from unittest.mock import MagicMock from swh.model.identifiers import CoreSWHID @@ -56,7 +57,16 @@ cooker.backend.put_bundle.assert_not_called() cooker.backend.set_status.assert_called_with(TEST_BUNDLE_TYPE, TEST_SWHID, "failed") - assert "Nope" not in cooker.backend.set_progress.call_args[0][2] + assert cooker.backend.set_progress.call_args[0][2].startswith( + textwrap.dedent( + """\ + Internal Server Error. This incident will be reported. + The full error was: + + Traceback (most recent call last): + """ + ) + ) cooker.backend.send_notif.assert_called_with(TEST_BUNDLE_TYPE, TEST_SWHID)