From 69b7e50735608bef4c59a94fb568d7adc43ea547 Mon Sep 17 00:00:00 2001 From: akucharska Date: Thu, 21 Nov 2024 15:46:44 +0100 Subject: [PATCH] Fix deployment status properly on deployments list, details and incluster overview --- src/resources/Deployments/DeploymentDetails.js | 7 ++++++- src/resources/Deployments/DeploymentStatus.js | 2 +- .../NamespaceWorkloads/NamespaceWorkloadsHelpers.js | 8 ++++++-- .../components/ConditionList/ConditionList.tsx | 2 ++ .../ExpandableListItem/ExpandableListItem.tsx | 12 ++++++++---- 5 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/resources/Deployments/DeploymentDetails.js b/src/resources/Deployments/DeploymentDetails.js index 5740639484..c6448828a9 100644 --- a/src/resources/Deployments/DeploymentDetails.js +++ b/src/resources/Deployments/DeploymentDetails.js @@ -64,7 +64,12 @@ export function DeploymentDetails(props) { const statusConditions = deployment => { return deployment?.status?.conditions?.map(condition => { return { - header: { titleText: condition.type, status: condition.status }, + header: { + titleText: condition.type, + status: condition.status, + overrideStatusType: + condition.type === 'ReplicaFailure' ? 'False' : condition.status, + }, message: condition.message, }; }); diff --git a/src/resources/Deployments/DeploymentStatus.js b/src/resources/Deployments/DeploymentStatus.js index 5bf2456caf..0fb4fe10d3 100644 --- a/src/resources/Deployments/DeploymentStatus.js +++ b/src/resources/Deployments/DeploymentStatus.js @@ -4,7 +4,7 @@ import { RunningPodsStatus } from 'shared/components/RunningPodsStatus'; export function DeploymentStatus({ deployment }) { const running = deployment.status.readyReplicas || 0; - const expected = deployment.status.replicas || 0; + const expected = deployment.status.replicas || deployment.spec.replicas || 0; return ; } diff --git a/src/resources/Namespaces/NamespaceWorkloads/NamespaceWorkloadsHelpers.js b/src/resources/Namespaces/NamespaceWorkloads/NamespaceWorkloadsHelpers.js index 2e72432885..572ef6f4b8 100644 --- a/src/resources/Namespaces/NamespaceWorkloads/NamespaceWorkloadsHelpers.js +++ b/src/resources/Namespaces/NamespaceWorkloads/NamespaceWorkloadsHelpers.js @@ -1,8 +1,12 @@ import { calculatePodState } from 'resources/Pods/PodStatus'; export function getHealthyReplicasCount(resource) { - return resource?.filter(r => r.status.replicas === r.status.readyReplicas) - ?.length; + return resource?.filter( + r => + r.status.replicas && + r.status.readyReplicas && + r.status.replicas === r.status.readyReplicas, + )?.length; } export const PodStatusCounterKey = { diff --git a/src/shared/components/ConditionList/ConditionList.tsx b/src/shared/components/ConditionList/ConditionList.tsx index 397c7390b5..dae0b0dab3 100644 --- a/src/shared/components/ConditionList/ConditionList.tsx +++ b/src/shared/components/ConditionList/ConditionList.tsx @@ -18,6 +18,7 @@ type ConditionItem = { type ConditionHeader = { titleText: string | ReactNode; status?: string; + overrideStatusType?: string; }; export const ConditionList = ({ @@ -34,6 +35,7 @@ export const ConditionList = ({ key={index} header={cond.header?.titleText} status={cond.header?.status} + overrideStatusType={cond.header?.overrideStatusType} content={cond.message} customContent={cond.customContent} /> diff --git a/src/shared/components/ExpandableListItem/ExpandableListItem.tsx b/src/shared/components/ExpandableListItem/ExpandableListItem.tsx index 545afc3a9b..65db3d66a8 100644 --- a/src/shared/components/ExpandableListItem/ExpandableListItem.tsx +++ b/src/shared/components/ExpandableListItem/ExpandableListItem.tsx @@ -8,6 +8,7 @@ import './ExpandableListItem.scss'; type ExpandableListItemProps = { header: string | ReactNode; status?: string; + overrideStatusType?: string; content?: string; customContent?: CustomContent[]; }; @@ -21,12 +22,18 @@ export type CustomContent = { export const ExpandableListItem = ({ header, status, + overrideStatusType, content, customContent, }: ExpandableListItemProps) => { const { t } = useTranslation(); const [expanded, setExpanded] = useState(false); + let statusType = status === 'True' ? 'Success' : 'Error'; + if (overrideStatusType !== undefined) { + statusType = overrideStatusType === 'True' ? 'Success' : 'Error'; + } + return ( <> + {status} )}