From e8232fef364dbea7f9715760f649df8a3ffe3e7e Mon Sep 17 00:00:00 2001 From: Adar Nimrod Date: Thu, 14 Mar 2024 19:15:23 +0200 Subject: [PATCH] Fix broker queues API with Redis. With non-AMPQ brokers `get_manager_client` returns `None` for the client which obviously doesn't have the `is_alive()` method. So we need to check if the connection driver type is AMQP otherwise `/v1/broker/queues` returns 503 with a `broker_not_reachable` error. Fix the same issue with `purge_queue()` which I haven't encountered. --- app/leek/api/control/stats.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/leek/api/control/stats.py b/app/leek/api/control/stats.py index 809ecd7..0238873 100644 --- a/app/leek/api/control/stats.py +++ b/app/leek/api/control/stats.py @@ -133,7 +133,8 @@ def get_subscription_queues(app_name, app_env, hide_pid_boxes=True): # noinspection PyBroadException try: connection, client = get_manager_client(subscription) - client.is_alive() + if connection.transport.driver_type == "amqp": + client.is_alive() except NetworkError: return responses.wrong_access_refused except Exception: @@ -192,7 +193,8 @@ def purge_queue(app_name, app_env, queue_name): # noinspection PyBroadException try: connection, client = get_manager_client(subscription) - client.is_alive() + if connection.transport.driver_type == "amqp": + client.is_alive() except NetworkError: return responses.wrong_access_refused except Exception: