From dd1378258418c047864f3e8fc2b5bc80fb27ae1d Mon Sep 17 00:00:00 2001 From: Sanjay Chari Date: Tue, 15 Mar 2022 13:25:12 +0530 Subject: [PATCH] Fix pacemaker collectd plugin The pacemaker collectd plugin fails with the error [error] Unhandled python exception in read callback: UnboundLocalError: local variable 'val' referenced before assignment on OSP 16.2. This patch fixes the issue. Change-Id: Ia004f3fb8c60f917d38ad580007e0757b4a20a44 --- .../files/collectd_pacemaker_monitoring.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/browbeat-containers/collectd-openstack/files/collectd_pacemaker_monitoring.py b/browbeat-containers/collectd-openstack/files/collectd_pacemaker_monitoring.py index 923c58eab..6e9caba95 100644 --- a/browbeat-containers/collectd-openstack/files/collectd_pacemaker_monitoring.py +++ b/browbeat-containers/collectd-openstack/files/collectd_pacemaker_monitoring.py @@ -42,6 +42,8 @@ def read_func(): "redis_resource_failures", "ovn_resource_failures", "cinder_resource_failures"] for component in components_list: + val = 0 + if component == "total_nodes": for line in latest_output[-1::-1]: if "nodes configured" in line: @@ -71,7 +73,6 @@ def read_func(): elif "resource_total_count" in component: resource = component.split("_")[0] - val = 0 # Flag to make sure that failures are not counted # in resource total count. is_failures_total = False @@ -93,7 +94,6 @@ def read_func(): elif "resource_master_count" in component: resource = component.split("_")[0] - val = 0 # Flag to make sure that failures are not counted # in resource master count is_failures_master = False @@ -115,7 +115,6 @@ def read_func(): if "daemon_status" in component: daemon = component.split("_")[0] - val = 0 for line in latest_output: if daemon+":" in line and "active/enabled" in line: val = 1 @@ -123,7 +122,6 @@ def read_func(): if "resource_failures" in component: resource = component.split("_")[0] - val = 0 is_failures = False for line in latest_output[-1::-1]: if "Failed" in line: