From 4c3f235e05844ce67422da41bf5dd869b251e265 Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Fri, 1 Dec 2023 16:08:13 -0500 Subject: [PATCH] Avoid running fault updates in maintenance mode When the cluster is in maintenance mode, all faults should be ignored. --- .../pvchealthd/objects/MonitoringInstance.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/health-daemon/pvchealthd/objects/MonitoringInstance.py b/health-daemon/pvchealthd/objects/MonitoringInstance.py index e14c52a9..cb128c7a 100644 --- a/health-daemon/pvchealthd/objects/MonitoringInstance.py +++ b/health-daemon/pvchealthd/objects/MonitoringInstance.py @@ -512,7 +512,7 @@ class MonitoringInstance(object): # If a fault already exists with this ID, just update the time if not self.zkhandler.exists("base.faults"): self.logger.out( - "Skipping fault reporting for {fault_id} due to missing Zookeeper schemas", + f"Skipping fault reporting for {fault_id} due to missing Zookeeper schemas", state="w", ) return @@ -522,7 +522,20 @@ class MonitoringInstance(object): self.logger.out( f"Updating fault {fault_id}: {fault_message} @ {fault_time}", state="i" ) + else: + self.logger.out( + f"Generating fault {fault_id}: {fault_message} @ {fault_time}", + state="i", + ) + if self.zkhandler.read("base.config.maintenance") == "true": + self.logger.out( + f"Skipping fault reporting for {fault_id} due to maintenance mode", + state="w", + ) + return + + if fault_id in existing_faults: self.zkhandler.write( [ (("faults.last_time", fault_id), str(fault_time)), @@ -530,10 +543,6 @@ class MonitoringInstance(object): ) # Otherwise, generate a new fault event else: - self.logger.out( - f"Generating fault {fault_id}: {fault_message} @ {fault_time}", - state="i", - ) self.zkhandler.write( [ (("faults.id", fault_id), ""),