From 22fcd05a0db45839d37a72f7d002635772920c85 Mon Sep 17 00:00:00 2001 From: Nicholas Devenish Date: Wed, 6 Sep 2023 13:38:55 +0100 Subject: [PATCH] configure_rabbitmq: Specifically handle VHost 404 (#241) Our current configuration doesn't actually specify vhost, so if you are trying to configure a fresh RabbitMQ then you will get apparently mysterious failures. --- HISTORY.rst | 1 + src/zocalo/cli/configure_rabbitmq.py | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/HISTORY.rst b/HISTORY.rst index e850adb..3459dbd 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -4,6 +4,7 @@ History Unreleased ---------- +* ``zocalo.configure_rabbitmq``: Show explicit error when VHost not created. 0.30.2 (2023-09-06) ------------------- diff --git a/src/zocalo/cli/configure_rabbitmq.py b/src/zocalo/cli/configure_rabbitmq.py index a5398c3..5d9b7e9 100644 --- a/src/zocalo/cli/configure_rabbitmq.py +++ b/src/zocalo/cli/configure_rabbitmq.py @@ -458,6 +458,13 @@ def run(): permanent_bindings.append(b) update_config(api, binding_specs, permanent_bindings) except requests.exceptions.HTTPError as e: + # Specially handle the VHost error, as we used to not setup vhosts + try: + if e.response.json()["reason"] == "vhost_not_found": + logger.error(f"Error 404: VHost not found for url: {e.response.url}") + sys.exit(1) + except Exception: + raise logger.error(e) sys.exit(1)