Skip to content

[release-4.18] OCPBUGS-53172: Include init containers in readiness count if ready and started is true #14884

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: release-4.18
Choose a base branch
from
Open
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
24 changes: 14 additions & 10 deletions frontend/public/module/k8s/pods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,17 +198,21 @@ export const podRestarts = (pod: PodKind): number => {
};

export const podReadiness = (pod: PodKind): { readyCount: number; totalContainers: number } => {
// Don't include init containers in readiness count. This is consistent with the CLI.
// Include init containers in readiness count if ready and started is true. This is consistent with the CLI.
const containerStatuses = pod?.status?.containerStatuses || [];
return containerStatuses.reduce(
(acc, { ready }: ContainerStatus) => {
if (ready) {
acc.readyCount = acc.readyCount + 1;
}
return acc;
},
{ readyCount: 0, totalContainers: containerStatuses.length },
);
const initContainerStatuses = pod?.status?.initContainerStatuses || [];

const totalContainers =
containerStatuses.length + initContainerStatuses.filter(({ started }) => started).length;

const readyCount =
containerStatuses.reduce((acc, { ready }: ContainerStatus) => (ready ? acc + 1 : acc), 0) +
initContainerStatuses.reduce(
(acc, { started, ready }: ContainerStatus) => (started && ready ? acc + 1 : acc),
0,
);

return { readyCount, totalContainers };
};

// This logic is replicated from k8s (at this writing, Kubernetes 1.17)
Expand Down