Merge ~adam-collard/maas-ci/+git/system-tests:vault-journal-output into ~maas-committers/maas-ci/+git/system-tests:master

Proposed by Adam Collard
Status: Merged
Approved by: Adam Collard
Approved revision: fcd5bc45326e3948ec7f64c97f7f54ef8efd2681
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~adam-collard/maas-ci/+git/system-tests:vault-journal-output
Merge into: ~maas-committers/maas-ci/+git/system-tests:master
Diff against target: 63 lines (+16/-4)
2 files modified
systemtests/fixtures.py (+11/-3)
systemtests/vault.py (+5/-1)
Reviewer Review Type Date Requested Status
MAAS Lander Approve
Anton Troyanov Approve
Review via email: mp+434066@code.launchpad.net

Commit message

Log vault journal output on error.

To post a comment you must log in.
Revision history for this message
Anton Troyanov (troyanov) :
review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b vault-journal-output lp:~adam-collard/maas-ci/+git/system-tests into -b master lp:~maas-committers/maas-ci/+git/system-tests

STATUS: SUCCESS
COMMIT: fcd5bc45326e3948ec7f64c97f7f54ef8efd2681

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/systemtests/fixtures.py b/systemtests/fixtures.py
2index c60ef46..eb9790c 100644
3--- a/systemtests/fixtures.py
4+++ b/systemtests/fixtures.py
5@@ -15,7 +15,7 @@ from .api import MAAS_CONTAINER_CERTS_PATH, UnauthenticatedMAASAPIClient
6 from .config import ADMIN_EMAIL, ADMIN_PASSWORD, ADMIN_USER
7 from .lxd import CLILXD, get_lxd
8 from .region import MAASRegion
9-from .vault import Vault
10+from .vault import Vault, VaultNotReadyError
11
12 if TYPE_CHECKING:
13 from logging import Logger
14@@ -292,7 +292,8 @@ def vault(maas_container: str, config: dict[str, Any]) -> Optional[Vault]:
15 if not snap_channel:
16 return None
17
18- lxd = get_lxd(getLogger(f"{LOG_NAME}.vault"))
19+ vault_logger = getLogger(f"{LOG_NAME}.vault")
20+ lxd = get_lxd(vault_logger)
21 lxd.execute(maas_container, ["apt", "install", "--yes", "ssl-cert"])
22 lxd.execute(
23 maas_container, ["snap", "install", "vault", f"--channel={snap_channel}"]
24@@ -351,7 +352,14 @@ def vault(maas_container: str, config: dict[str, Any]) -> Optional[Vault]:
25 secrets_path="maas",
26 lxd=lxd,
27 )
28- vault.ensure_initialized()
29+ try:
30+ vault.ensure_initialized()
31+ except VaultNotReadyError as e:
32+ journalctl = lxd.execute(
33+ maas_container, ["journalctl", "--unit=vault", "--no-pager"]
34+ )
35+ vault_logger.exception(f"{e}\n{journalctl.stdout}")
36+ raise
37 vault.ensure_setup()
38 return vault
39
40diff --git a/systemtests/vault.py b/systemtests/vault.py
41index 21b15a4..9cb2848 100644
42--- a/systemtests/vault.py
43+++ b/systemtests/vault.py
44@@ -11,6 +11,10 @@ from .lxd import CLILXD
45 from .utils import retries
46
47
48+class VaultNotReadyError(Exception):
49+ pass
50+
51+
52 @dataclass
53 class Vault:
54 """Vault CLI wrapper to be run inside a container."""
55@@ -39,7 +43,7 @@ class Vault:
56 with suppress(subprocess.CalledProcessError):
57 return self.status()
58
59- raise RuntimeError("Vault never became ready")
60+ raise VaultNotReadyError(f"Vault at {self.addr} never became ready")
61
62 def status(self) -> dict[str, Any]:
63 """Return the Vault status."""

Subscribers

People subscribed via source and target branches

to all changes: