From 46af0470290baf202e5834c80a3dc0bcd0fea432 Mon Sep 17 00:00:00 2001 From: veds-g Date: Thu, 31 Oct 2024 16:24:40 +0530 Subject: [PATCH] pod info refresh timer Signed-off-by: veds-g --- .../partials/NodeInfo/partials/Pods/index.tsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/ui/src/components/pages/Pipeline/partials/Graph/partials/NodeInfo/partials/Pods/index.tsx b/ui/src/components/pages/Pipeline/partials/Graph/partials/NodeInfo/partials/Pods/index.tsx index ee7cfa998..a08d75cc3 100644 --- a/ui/src/components/pages/Pipeline/partials/Graph/partials/NodeInfo/partials/Pods/index.tsx +++ b/ui/src/components/pages/Pipeline/partials/Graph/partials/NodeInfo/partials/Pods/index.tsx @@ -65,6 +65,7 @@ export function Pods(props: PodsProps) { const [podSpecificInfo, setPodSpecificInfo] = useState< PodSpecificInfoProps | undefined >(undefined); + const [requestKey, setRequestKey] = useState(`${Date.now()}`); const getContainerInfo = useCallback((podsData, podName, containerName) => { const selectedPod = podsData?.find((pod) => pod?.name === podName); @@ -103,7 +104,7 @@ export function Pods(props: PodsProps) { type === "monoVertex" ? `/mono-vertices` : `/pipelines/${pipelineId}/vertices` - }/${vertexId}/pods` + }/${vertexId}/pods?refreshKey=${requestKey}` ); if (!response.ok) { throw new Error("Failed to fetch pod details"); @@ -137,12 +138,23 @@ export function Pods(props: PodsProps) { vertexId, getContainerInfo, getPodSpecificInfo, + requestKey, selectedPod, selectedContainer, setPodSpecificInfo, setContainerInfo, ]); + useEffect(() => { + // Refresh pod details every 30 sec + const interval = setInterval(() => { + setRequestKey(`${Date.now()}`); + }, 30000); + return () => { + clearInterval(interval); + }; + }, []); + // This useEffect notifies about the errors while querying for the pods of the vertex useEffect(() => { if (podsErr) notifyError(podsErr);