From cf646dfce2db86f01dd49349e1803da23de4ec85 Mon Sep 17 00:00:00 2001 From: suzhengwei Date: Wed, 4 Jan 2023 11:25:47 +0800 Subject: [PATCH] not retry to send notification for specific http exception When the host not added in the failover segment, it will raise 400(host with name *** could not be found). It should not retry to send notification in this case. Change-Id: I24a6aba97b834ae92dabe85196f01d27bb518b3c --- masakarimonitors/ha/masakari.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/masakarimonitors/ha/masakari.py b/masakarimonitors/ha/masakari.py index af9b873..bec13fb 100644 --- a/masakarimonitors/ha/masakari.py +++ b/masakarimonitors/ha/masakari.py @@ -74,10 +74,8 @@ class SendNotification(object): except Exception as e: if isinstance(e, exceptions.HttpException): - if e.status_code == 409: - msg = ("Stop retrying to send a notification because " - "same notification have been already sent.") - LOG.info("%s", msg) + if e.status_code in [400, 409]: + LOG.info(e) break if retry_count < api_retry_max: