Skip to content

Commit

Permalink
Reduce some unnecessary log churn
Browse files Browse the repository at this point in the history
If nothing has change since last log line, then there is no added value by
duplicating the text.
  • Loading branch information
khk-globus committed Apr 21, 2023
1 parent 712a560 commit 1c05be1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1132,8 +1132,9 @@ def provider_status(self):
"""
status = []
if self.provider:
log.trace("Getting the status of %s blocks.", list(self.blocks.values()))
status = self.provider.status(list(self.blocks.values()))
job_ids: list[str] = list(self.blocks.values())
log.trace("Getting the status of %s blocks.", job_ids)
status = self.provider.status(job_ids)
log.trace("The status is %s", status)

return status
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ def status(self, job_ids):
For example: {"RAW": 16}
"""
# This is a hack
log.debug("Getting Kubernetes provider status")
status = {}
for jid in job_ids:
if jid in self.resources_by_pod_name:
Expand Down
17 changes: 13 additions & 4 deletions compute_endpoint/globus_compute_endpoint/strategies/kube_simple.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging
import math
import time
from collections import defaultdict

from globus_compute_endpoint.logging_config import ComputeLogger
from globus_compute_endpoint.strategies.base import BaseStrategy
Expand Down Expand Up @@ -30,10 +31,11 @@ def __init__(self, *args, threshold=20, interval=1, max_idletime=60):
default: 60s
"""
log.info("KubeSimpleStrategy Initialized")
super().__init__(*args, threshold=threshold, interval=interval)
self.max_idletime = max_idletime
self.executors_idle_since = {}
self._task_type_status_msg = defaultdict(str)
log.info(f"KubeSimpleStrategy Initialized; max idle time: {max_idletime}s")

def strategize(self, *args, **kwargs):
try:
Expand All @@ -60,20 +62,27 @@ def _strategize(self, *args, **kwargs):
status = self.interchange.provider_status()
log.trace("Provider status : %s", status)

task_dbg_msg = (
"Endpoint has %s active tasks of %s, %s active blocks, "
"%s connected workers for %s"
)

for task_type in active_tasks.keys():
active_pods = status.get(task_type, 0)
active_slots = active_pods * workers_per_pod * managers_per_pod
active_tasks_per_type = active_tasks[task_type]

log.debug(
"Endpoint has %s active tasks of %s, %s active blocks, "
"%s connected workers for %s",
_tmp = task_dbg_msg % (
active_tasks_per_type,
task_type,
active_pods,
self.interchange.get_total_live_workers(),
task_type,
)
if _tmp != self._task_type_status_msg[task_type]:
# Quiet some not-helpful logs
self._task_type_status_msg[task_type] = _tmp
log.debug(_tmp)

# Reset the idle time if we are currently running tasks
if active_tasks_per_type > 0:
Expand Down

0 comments on commit 1c05be1

Please sign in to comment.