From 208527d85490cdfc551c6560ae5e10a50c85f1c4 Mon Sep 17 00:00:00 2001 From: Vedant Gupta <49195734+veds-g@users.noreply.github.com> Date: Mon, 3 Feb 2025 20:38:03 +0530 Subject: [PATCH] feat: moving ud containers logs as default in pods view (#2378) Signed-off-by: veds-g --- ui/src/utils/fetcherHooks/podsViewFetch.ts | 23 ++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/ui/src/utils/fetcherHooks/podsViewFetch.ts b/ui/src/utils/fetcherHooks/podsViewFetch.ts index 07520e66ad..8e251ca703 100644 --- a/ui/src/utils/fetcherHooks/podsViewFetch.ts +++ b/ui/src/utils/fetcherHooks/podsViewFetch.ts @@ -57,13 +57,20 @@ export const usePodsViewFetch = ( const containers: string[] = []; const containerSpecMap = new Map(); - const containersList = JSON.parse( - JSON.stringify(pod?.spec?.containers) - ); + const containersList: any[] = []; pod?.spec?.initContainers - ?.filter((initContainer: any) => initContainer?.restartPolicy === "Always") + ?.filter( + (initContainer: any) => + initContainer?.restartPolicy === "Always" + ) ?.forEach((container: any) => containersList.push(container)); + const specContainers = JSON.parse( + JSON.stringify(pod?.spec?.containers) + ); + + containersList.push(...specContainers); + containersList?.forEach((container: any) => { const cpu = container?.resources?.requests?.cpu; let cpuParsed: undefined | number; @@ -130,7 +137,7 @@ export const usePodsViewFetch = ( useEffect(() => { fetchPods(); - },[vertexId, requestKey, host]); + }, [vertexId, requestKey, host]); useEffect(() => { if (pods?.length) { @@ -243,10 +250,10 @@ export const usePodsViewFetch = ( // Retry fetching pods details if there is an error useEffect(() => { const currentTime = Date.now(); - if (podsDetailsErr && (currentTime - lastRetryTime > 5000)) { + if (podsDetailsErr && currentTime - lastRetryTime > 5000) { const retryFetch = setTimeout(() => { - fetchPodDetails(); - setLastRetryTime(currentTime); + fetchPodDetails(); + setLastRetryTime(currentTime); }, 5000); return () => clearTimeout(retryFetch);