Skip to content

Commit 972a646

Browse files
committed
fix: process pods only when all containers are running
Pods that are about to be deleted are ignored. Now we also require that all containers are in running state.
1 parent f94c201 commit 972a646

File tree

1 file changed

+8
-16
lines changed
  • src/supervisor/watchers/handlers

1 file changed

+8
-16
lines changed

src/supervisor/watchers/handlers/pod.ts

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -68,29 +68,21 @@ export async function handleReadyPod(
6868
}
6969

7070
export function isPodReady(pod: V1Pod): boolean {
71-
const podStatus = pod.status !== undefined;
71+
const isTerminating = pod.metadata?.deletionTimestamp !== undefined;
7272
const podStatusPhase = pod.status?.phase === PodPhase.Running;
73-
const podContainerStatuses = pod.status?.containerStatuses !== undefined;
74-
const containerReadyStatuses = pod.status?.containerStatuses?.some(
75-
(container) =>
76-
container.state !== undefined &&
77-
(container.state.running !== undefined ||
78-
container.state.waiting !== undefined),
79-
) as boolean;
73+
const containerReadyStatuses = Boolean(
74+
pod.status?.containerStatuses?.every(
75+
(container) => container.state?.running !== undefined,
76+
),
77+
);
8078

8179
const logContext = {
82-
podStatus,
80+
isTerminating,
8381
podStatusPhase,
84-
podContainerStatuses,
8582
containerReadyStatuses,
8683
};
8784
logger.debug(logContext, 'checking to see if pod is ready to process');
88-
return (
89-
podStatus &&
90-
podStatusPhase &&
91-
podContainerStatuses &&
92-
containerReadyStatuses
93-
);
85+
return !isTerminating && podStatusPhase && containerReadyStatuses;
9486
}
9587

9688
export async function paginatedNamespacedPodList(namespace: string): Promise<{

0 commit comments

Comments
 (0)