Skip to content

Commit 1c61ecd

Browse files
committed
T7528: only stop service if previously deployed
1 parent b3ebf8f commit 1c61ecd

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/conf_mode/service_monitoring_prometheus.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,19 @@ def generate(monitoring):
115115
# Delete systemd files
116116
if os.path.isfile(node_exporter_service_file):
117117
os.unlink(node_exporter_service_file)
118+
monitoring.update({'node_exporter_stop_required': {}})
118119

119120
if not monitoring or 'frr_exporter' not in monitoring:
120121
# Delete systemd files
121122
if os.path.isfile(frr_exporter_service_file):
122123
os.unlink(frr_exporter_service_file)
124+
monitoring.update({'frr_exporter_stop_required': {}})
123125

124126
if not monitoring or 'blackbox_exporter' not in monitoring:
125127
# Delete systemd files
126128
if os.path.isfile(blackbox_exporter_service_file):
127129
os.unlink(blackbox_exporter_service_file)
130+
monitoring.update({'blackbox_exporter_stop_required': {}})
128131

129132
if not monitoring:
130133
return None
@@ -173,11 +176,14 @@ def apply(monitoring):
173176
# Reload systemd manager configuration
174177
call('systemctl daemon-reload')
175178
if not monitoring or 'node_exporter' not in monitoring:
176-
call(f'systemctl stop {node_exporter_systemd_service}')
179+
if 'node_exporter_stop_required' in monitoring:
180+
call(f'systemctl stop {node_exporter_systemd_service}')
177181
if not monitoring or 'frr_exporter' not in monitoring:
178-
call(f'systemctl stop {frr_exporter_systemd_service}')
182+
if 'frr_exporter_stop_required' in monitoring:
183+
call(f'systemctl stop {frr_exporter_systemd_service}')
179184
if not monitoring or 'blackbox_exporter' not in monitoring:
180-
call(f'systemctl stop {blackbox_exporter_systemd_service}')
185+
if 'blackbox_exporter_stop_required' in monitoring:
186+
call(f'systemctl stop {blackbox_exporter_systemd_service}')
181187

182188
if not monitoring:
183189
return

0 commit comments

Comments
 (0)