Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update all_resources_utilization info lego #1041

Merged
merged 2 commits into from
Apr 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def k8s_get_all_resources_utilization_info_printer(data):

print(f"\n{resource.capitalize()}:")
if not rows: # Check if the resource list is empty
print(f"No {resource} found in {namespace} namespace.")
# print(f"No {resource} found in {namespace} namespace.")
continue # Skip to the next resource

if resource == 'pods':
Expand Down Expand Up @@ -50,7 +50,9 @@ def k8s_get_all_resources_utilization_info(handle, namespace: str = "") -> Dict:

namespace_option = f"--namespace={namespace}" if namespace else "--all-namespaces"

resources = ['pods', 'jobs', 'persistentvolumeclaims']
resources = ['pods', 'jobs'
# 'persistentvolumeclaims'
]
data = {resource: [] for resource in resources}
data['namespace'] = namespace # Store namespace in data dict

Expand Down Expand Up @@ -97,12 +99,19 @@ def k8s_get_all_resources_utilization_info(handle, namespace: str = "") -> Dict:
cpu_usage, memory_usage = utilization_map.get(key, ('N/A', 'N/A'))
data[resource].append([ns, name, status, cpu_usage, memory_usage])
else:
status = None
if resource == 'jobs':
conditions = item['status'].get('conditions', [])
if conditions:
status = conditions[-1]['type']
elif resource == 'persistentvolumeclaims':
status = item['status']['phase']
data[resource].append([ns, name, status])
if status in ['Complete']:
continue
# elif resource == 'persistentvolumeclaims':
# status = item['status']['phase']
if status is not None:
data[resource].append([ns, name, status])

# If resource has no objects to display, filter it out
data = {k: v for k, v in data.items() if v}

return data
Loading