You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by wu...@apache.org on 2022/11/24 07:54:56 UTC
[ambari] branch trunk updated: AMBARI-25621: Ambari soft alert never become hard (#3561)
This is an automated email from the ASF dual-hosted git repository.
wuzhiguo pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git
The following commit(s) were added to refs/heads/trunk by this push:
new 9c465c30f4 AMBARI-25621: Ambari soft alert never become hard (#3561)
9c465c30f4 is described below
commit 9c465c30f470cbccd4ea44a0f3693c657204cedf
Author: Yu Hou <52...@qq.com>
AuthorDate: Thu Nov 24 15:54:51 2022 +0800
AMBARI-25621: Ambari soft alert never become hard (#3561)
---
.../python/ambari_agent/AlertStatusReporter.py | 27 +++++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)
diff --git a/ambari-agent/src/main/python/ambari_agent/AlertStatusReporter.py b/ambari-agent/src/main/python/ambari_agent/AlertStatusReporter.py
index dd17c5ab77..c512ff2128 100644
--- a/ambari-agent/src/main/python/ambari_agent/AlertStatusReporter.py
+++ b/ambari-agent/src/main/python/ambari_agent/AlertStatusReporter.py
@@ -42,6 +42,7 @@ class AlertStatusReporter(threading.Thread):
self.stale_alerts_monitor = initializer_module.stale_alerts_monitor
self.server_responses_listener = initializer_module.server_responses_listener
self.reported_alerts = defaultdict(lambda:defaultdict(lambda:[]))
+ self.alert_repeats = defaultdict(lambda:defaultdict(lambda:[]))
self.send_alert_changes_only = initializer_module.config.send_alert_changes_only
threading.Thread.__init__(self)
@@ -83,6 +84,7 @@ class AlertStatusReporter(threading.Thread):
alert_name = alert['name']
self.reported_alerts[cluster_id][alert_name] = [alert[field] for field in self.FIELDS_CHANGED_RESEND_ALERT]
+ self.alert_repeats[cluster_id][alert_name] += 1
def get_changed_alerts(self, alerts):
"""
@@ -92,9 +94,28 @@ class AlertStatusReporter(threading.Thread):
for alert in alerts:
cluster_id = alert['clusterId']
alert_name = alert['name']
-
- if [alert[field] for field in self.FIELDS_CHANGED_RESEND_ALERT] != self.reported_alerts[cluster_id][alert_name]:
- changed_alerts.append(alert)
+ alert_state = alert['state']
+
+ alert_definitions = filter(lambda definition: definition['name'] == alert_name,
+ self.alert_definitions_cache[cluster_id]['alertDefinitions'])
+ if alert_definitions:
+ alert_definition = alert_definitions[0]
+ definition_tolerance_enabled = alert_definition['repeat_tolerance_enabled']
+ if definition_tolerance_enabled:
+ alert_tolerance = int(alert_definition['repeat_tolerance'])
+ else:
+ alert_tolerance = int(self.initializer_module.configurations_cache[cluster_id]['configurations']['cluster-env']['alerts_repeat_tolerance'])
+
+ # if status changed then add alert + reset counter
+ # if status not changed and counter is not satisfied then add alert (but only for not-OK)
+ if [alert[field] for field in self.FIELDS_CHANGED_RESEND_ALERT] != self.reported_alerts[cluster_id][alert_name]:
+ changed_alerts.append(alert)
+ self.alert_repeats[cluster_id][alert_name] = 0
+ elif self.alert_repeats[cluster_id][alert_name] < alert_tolerance and alert_state != 'OK':
+ changed_alerts.append(alert)
+ else:
+ logger.warn("Cannot find alert definition for alert='{0}', alert_state='{1}'."
+ .format(alert_name, alert_state))
return changed_alerts
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@ambari.apache.org
For additional commands, e-mail: commits-help@ambari.apache.org