Update define-nagios-hosts.py error handling

Currently if list_nodes fails in the define-nagios-hosts.py
script, the entire script will fail with some unknown
error. This change updates the script to better catch
and report any exceptions that happen.

Change-Id: I0e33f47af8ad8f69f2f1e4a5b377d0e31d0c0819
This commit is contained in:
Gage Hugo
2022-03-15 14:32:22 -05:00
parent 4384a78cb1
commit 19317b5c6c

View File

@@ -98,8 +98,9 @@ def get_kubernetes_node_list():
kube_api = kubernetes.client.CoreV1Api()
try:
node_list = kube_api.list_node(pretty='false', limit=100, timeout_seconds=60)
except ApiException as e:
except Exception as e:
print("Exception when calling CoreV1Api->list_node: %s\n" % e)
sys.exit(NAGIOS_CRITICAL)
return node_list.items
def update_config_file(object_file_loc):