From c6f69f85c9a15c9187dab9d835cb1a76f74cfc48 Mon Sep 17 00:00:00 2001 From: andersonid Date: Thu, 2 Oct 2025 15:47:13 -0300 Subject: [PATCH] fix: correct historical analysis endpoint and Chart.js loading - Fix endpoint to use get_all_pods() instead of non-existent get_pods_by_selector() - Move Chart.js scripts to end of body for proper loading order - Add proper error handling for workload not found cases - Ensure Chart.js is available before creating graphs --- app/api/routes.py | 13 +++++++------ app/static/index.html | 7 ++++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/app/api/routes.py b/app/api/routes.py index 614c844..1d0c0ff 100644 --- a/app/api/routes.py +++ b/app/api/routes.py @@ -1268,13 +1268,14 @@ async def get_workload_historical_details( ): """Get detailed historical analysis for a specific workload""" try: - # Get pods for this workload - pods = await k8s_client.get_pods_by_selector( - namespace=namespace, - selector={'app': workload} - ) + # Get all pods and filter by namespace and workload + all_pods = await k8s_client.get_all_pods() + workload_pods = [ + pod for pod in all_pods + if pod.namespace == namespace and _extract_workload_name(pod.name) == workload + ] - if not pods: + if not workload_pods: raise HTTPException(status_code=404, detail=f"Workload {workload} not found in namespace {namespace}") # Get historical data from Prometheus diff --git a/app/static/index.html b/app/static/index.html index 437199d..31e5d7f 100644 --- a/app/static/index.html +++ b/app/static/index.html @@ -17,9 +17,6 @@ - - -