Skip to content
Merged
Show file tree
Hide file tree
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
13 changes: 13 additions & 0 deletions ui/src/hooks/usePodStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,25 @@ export const usePodStatus = (
url: `${axios.defaults.baseURL}/rest-api/v1/insight/summary`,
method: 'GET',
manual: true,
// A pod row can still be listed from the search index for a moment after
// it's actually gone from the live cluster, so a not-found response here
// is an expected, non-actionable state rather than a real error.
silentError: true,
})

useEffect(() => {
if (summaryResponse?.success) {
statusRef.current = summaryResponse?.data?.resource?.status || 'unknown'
setLoading(false)
} else if (summaryResponse) {
// Request completed but failed (e.g. pod not found live) -- resolve to
// Unavailable instead of spinning forever.
console.warn(
`Failed to fetch live status for pod ${namespace}/${name}:`,
summaryResponse?.message,
)
statusRef.current = 'Unavailable'
setLoading(false)
} else {
statusRef.current = 'Loading'
setLoading(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const PodStatusCell = ({ cluster, namespace, name }) => {
Running: 'success',
Terminated: 'default',
Unknown: 'error',
Unavailable: 'default',
}[status.current] || 'warning'

return <Tag color={color}>{status.current}</Tag>
Expand Down
28 changes: 18 additions & 10 deletions ui/src/utils/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ export const useAxios = ({
method = 'GET',
callbackFn = null,
successParams = {},
// When true, a failed `/rest-api` response still updates `response` (so
// callers can resolve out of a loading state) but skips the global error
// notification. Useful for per-item background lookups (e.g. polling many
// rows' live status) where a single item being not-found is an expected,
// non-actionable state and shouldn't surface as a user-facing error toast.
silentError = false,
}) => {
const [options, setOptions] = useState({
url,
Expand Down Expand Up @@ -70,17 +76,19 @@ export const useAxios = ({
return
}
if (res?.config?.url?.includes('/rest-api') && !res?.data?.success) {
notification.error({
message: `${res?.status}`,
description: `${res?.data?.message}`,
})
} else {
setResponse({
...res?.data,
...(callbackFn ? { callbackFn } : {}),
...(successParams ? { successParams } : {}),
})
if (!silentError) {
notification.error({
message: `${res?.status}`,
description: `${res?.data?.message}`,
})
return
}
}
setResponse({
...res?.data,
...(callbackFn ? { callbackFn } : {}),
...(successParams ? { successParams } : {}),
})
}

useEffect(() => {
Expand Down
Loading