Skip to content

Commit eecd7c3

Browse files
authored
Exclude archived components from health ping (#89)
1 parent 65043f5 commit eecd7c3

1 file changed

Lines changed: 29 additions & 28 deletions

File tree

health_ping.py

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -306,36 +306,37 @@ def start_health_ping(self):
306306
try:
307307
components = self.services.sc.get_all_records(self.services.sc.components_get)
308308
for component in components:
309-
c_name = component.get('name')
310-
for env in component.get('envs', []):
311-
env_id = env.get('documentId', '')
312-
if env.get('url') and env.get('monitor'):
313-
# moving the endpoint_tuple loop inside the process_env
314-
# to avoid duplication of build_image_tag
315-
# if it's present in both health and info
316-
thread = threading.Thread(
317-
target=self._process_env,
318-
args=(c_name, component, env_id, env, endpoints_list, self.services),
319-
daemon=True,
320-
)
321-
main_threads.append(thread)
322-
# Apply limit on worker threads only (excluding main thread)
323-
# to avoid github secondary API rate limit.
324-
worker_limit = max(1, max_threads)
325-
while (threading.active_count() - 1) >= worker_limit:
309+
if not component.get('archived'):
310+
c_name = component.get('name')
311+
for env in component.get('envs', []):
312+
env_id = env.get('documentId', '')
313+
if env.get('url') and env.get('monitor'):
314+
# moving the endpoint_tuple loop inside the process_env
315+
# to avoid duplication of build_image_tag
316+
# if it's present in both health and info
317+
thread = threading.Thread(
318+
target=self._process_env,
319+
args=(c_name, component, env_id, env, endpoints_list, self.services),
320+
daemon=True,
321+
)
322+
main_threads.append(thread)
323+
# Apply limit on worker threads only (excluding main thread)
324+
# to avoid github secondary API rate limit.
325+
worker_limit = max(1, max_threads)
326+
while (threading.active_count() - 1) >= worker_limit:
327+
log_info(
328+
f'Active Threads={threading.active_count()}, '
329+
f'Max Threads={worker_limit} - backing off for a few seconds'
330+
)
331+
sleep(3)
332+
thread.start()
326333
log_info(
327-
f'Active Threads={threading.active_count()}, '
328-
f'Max Threads={worker_limit} - backing off for a few seconds'
334+
f'Started thread for {env.get("name")} (active threads: '
335+
f'{threading.active_count()})'
329336
)
330-
sleep(3)
331-
thread.start()
332-
log_info(
333-
f'Started thread for {env.get("name")} (active threads: '
334-
f'{threading.active_count()})'
335-
)
336-
else:
337-
continue
338-
log_debug(f'Active threads: {threading.active_count()}')
337+
else:
338+
continue
339+
log_debug(f'Active threads: {threading.active_count()}')
339340

340341
# Allow the threads to finish before sleeping
341342
stuck_threads = 0

0 commit comments

Comments
 (0)