Skip to content

Commit

Permalink
add message to kubernetes kill if no pods were found to be killed. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
saikonen authored Sep 26, 2024
1 parent cd9df22 commit aaa2102
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion metaflow/plugins/kubernetes/kubernetes_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@ def kill_pods(self, flow_name, run_id, user, echo):
job_api = self._client.BatchV1Api()
pods = self._find_active_pods(flow_name, run_id, user)

active_pods = False

def _kill_pod(pod):
active_pods = True
echo("Killing Kubernetes pod %s\n" % pod.metadata.name)
try:
stream(
Expand Down Expand Up @@ -155,7 +158,10 @@ def _kill_pod(pod):
echo("failed to kill pod %s - %s" % (pod.metadata.name, str(e)))

with ThreadPoolExecutor() as executor:
executor.map(_kill_pod, list(pods))
executor.map(_kill_pod, pods)

if not active_pods:
echo("No active Kubernetes pods found for run *%s*" % run_id)

def jobset(self, **kwargs):
return KubernetesJobSet(self, **kwargs)
Expand Down

0 comments on commit aaa2102

Please sign in to comment.