Skip to content

Commit

Permalink
Streamline active_pods function
Browse files Browse the repository at this point in the history
  • Loading branch information
jaclark5 committed Feb 6, 2025
1 parent c4c809c commit c6b20a8
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions kubecustom/pod.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,25 +319,22 @@ def get_active_tasks(pod_list, verbose=True, namespace=None):
line_array = line.split()
tasks = int(line_array[-7])
output[pod_name] = tasks
stats[tasks] += 1
if verbose:
print(f" Pod: {pod_name}, Number of Tasks {tasks}")
break

if pod_name not in output:
output[pod_name] = None
stats["None Yet"] += 1
if verbose:
print(f" Pod: {pod_name}, Number of Tasks None Yet")
output[pod_name] = "None Yet"

except Exception:
stats[None] += 1
output[pod_name] = None
if verbose:
print(f" Pod: {pod_name}, Number of Tasks NA")

stats[output[pod_name]] += 1
if verbose:
print(f" Pod: {pod_name}, Number of Tasks {output[pod_name]}")

if verbose:
print(stats)
print("Count of Number of Tasks: (Npods = 1 + Nreplicas)")
for task, count in stats.items():
print(f" {task}: {count}")

return output, stats

Expand Down

0 comments on commit c6b20a8

Please sign in to comment.