Skip to content

Commit

Permalink
Added exception handling for default alertseverity label
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandhya1874 committed Dec 19, 2024
1 parent 89e1cc3 commit edad2d7
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions github_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,8 +714,11 @@ def process_repo(**component):
if 'dev' in alert_severity_label_envs:
label = alert_severity_label_envs["dev"]["alert_severity_label"]
else:
label = helm_default_values['generic-prometheus-alerts']['alertSeverity']
print(f'Alert severity label not found for dev environment in {c_name}, getting default value {label}')
try:
label = helm_default_values['generic-prometheus-alerts']['alertSeverity']
print(f'Alert severity label not found for dev environment in {c_name}, getting default value {label}')
except KeyError:
pass
if label:
e.update({'alert_severity_label': label})
channel = find_channel_by_severity_label(label)
Expand Down Expand Up @@ -749,8 +752,11 @@ def process_repo(**component):
if 'development' in alert_severity_label_envs:
label = alert_severity_label_envs["developement"]["alert_severity_label"]
else:
label = helm_default_values['generic-prometheus-alerts']['alertSeverity']
print(f'Alert severity label not found for developement environment in {c_name}, getting default value {label}')
try:
label = helm_default_values['generic-prometheus-alerts']['alertSeverity']
print(f'Alert severity label not found for development environment in {c_name}, getting default value {label}')
except KeyError:
pass
if label:
e.update({'alert_severity_label': label})
channel = find_channel_by_severity_label(label)
Expand Down Expand Up @@ -852,8 +858,11 @@ def process_repo(**component):
if env_name in alert_severity_label_envs:
label = alert_severity_label_envs[env_name]["alert_severity_label"]
else:
label = helm_default_values['generic-prometheus-alerts']['alertSeverity']
print(f'Alert severity label not found for {env_name} environment in {c_name}, getting default value {label}')
try:
label = helm_default_values['generic-prometheus-alerts']['alertSeverity']
print(f'Alert severity label not found for {env_name} environment in {c_name}, getting default value {label}')
except KeyError:
pass
if label:
e.update({'alert_severity_label': label})
channel = find_channel_by_severity_label(label)
Expand Down

0 comments on commit edad2d7

Please sign in to comment.