Skip to content

Commit

Permalink
fix(ui): soften readiness gate failure message (argoproj#13972) (argo…
Browse files Browse the repository at this point in the history
…proj#14076)

* fix(ui): soften readiness gate failure message (argoproj#13972)

Signed-off-by: Michael Crenshaw <[email protected]>

* null check everything

Signed-off-by: Michael Crenshaw <[email protected]>

---------

Signed-off-by: Michael Crenshaw <[email protected]>
  • Loading branch information
crenshaw-dev authored Jun 15, 2023
1 parent 3185cc0 commit bbc51fb
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,9 @@ import * as models from '../../../shared/models';
import {services} from '../../../shared/services';
import {ResourceTreeNode} from '../application-resource-tree/application-resource-tree';
import {ApplicationResourcesDiff} from '../application-resources-diff/application-resources-diff';
import {
ComparisonStatusIcon,
formatCreationTimestamp,
getPodReadinessGatesState,
getPodReadinessGatesState as _getPodReadinessGatesState,
getPodStateReason,
HealthStatusIcon
} from '../utils';
import {ComparisonStatusIcon, formatCreationTimestamp, getPodReadinessGatesState, getPodStateReason, HealthStatusIcon} from '../utils';
import './application-node-info.scss';
import {ReadinessGatesFailedWarning} from './readiness-gates-failed-warning';
import {ReadinessGatesNotPassedWarning} from './readiness-gates-not-passed-warning';

const RenderContainerState = (props: {container: any}) => {
const state = (props.container.state?.waiting && 'waiting') || (props.container.state?.terminated && 'terminated') || (props.container.state?.running && 'running');
Expand Down Expand Up @@ -278,6 +271,14 @@ export const ApplicationNodeInfo = (props: {
}

const readinessGatesState = React.useMemo(() => {
// If containers are not ready then readiness gate status is not important.
if (!props.live?.status?.containerStatuses?.length) {
return null;
}
if (props.live?.status?.containerStatuses?.some((containerStatus: {ready: boolean}) => !containerStatus.ready)) {
return null;
}

if (props.live && props.node?.kind === 'Pod') {
return getPodReadinessGatesState(props.live);
}
Expand All @@ -287,7 +288,7 @@ export const ApplicationNodeInfo = (props: {

return (
<div>
{Boolean(readinessGatesState) && <ReadinessGatesFailedWarning readinessGatesState={readinessGatesState} />}
{Boolean(readinessGatesState) && <ReadinessGatesNotPassedWarning readinessGatesState={readinessGatesState} />}
<div className='white-box'>
<div className='white-box__details'>
{attributes.map(attr => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
.white-box {
&__readiness-gates-alert {
padding: 20px;
border-left: 6px solid $argo-status-failed-color !important;
border-left: 6px solid $argo-status-warning-color !important;

ul {
margin-bottom: 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import * as React from 'react';
import {selectPostfix} from '../utils';

import './readiness-gates-failed-warning.scss';
import './readiness-gates-not-passed-warning.scss';

export interface ReadinessGatesFailedWarningProps {
export interface ReadinessGatesNotPassedWarningProps {
readinessGatesState: {
nonExistingConditions: string[];
failedConditions: string[];
notPassedConditions: string[];
};
}

export const ReadinessGatesFailedWarning = ({readinessGatesState}: ReadinessGatesFailedWarningProps) => {
if (readinessGatesState.failedConditions.length > 0 || readinessGatesState.nonExistingConditions.length > 0) {
export const ReadinessGatesNotPassedWarning = ({readinessGatesState}: ReadinessGatesNotPassedWarningProps) => {
if (readinessGatesState.notPassedConditions.length > 0 || readinessGatesState.nonExistingConditions.length > 0) {
return (
<div className='white-box white-box__readiness-gates-alert'>
<h5>Readiness Gates Failing: </h5>
<h5>Readiness Gates Not Passing: </h5>
<ul>
{readinessGatesState.failedConditions.length > 0 && (
{readinessGatesState.notPassedConditions.length > 0 && (
<li>
The status of pod readiness gate{selectPostfix(readinessGatesState.failedConditions, '', 's')}{' '}
{readinessGatesState.failedConditions
The status of pod readiness gate{selectPostfix(readinessGatesState.notPassedConditions, '', 's')}{' '}
{readinessGatesState.notPassedConditions
.map(t => `"${t}"`)
.join(', ')
.trim()}{' '}
{selectPostfix(readinessGatesState.failedConditions, 'is', 'are')} False.
{selectPostfix(readinessGatesState.notPassedConditions, 'is', 'are')} False.
</li>
)}
{readinessGatesState.nonExistingConditions.length > 0 && (
Expand Down
7 changes: 4 additions & 3 deletions ui/src/app/applications/components/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -946,11 +946,12 @@ export function getPodStateReason(pod: appModels.State): {message: string; reaso
return {reason, message, netContainerStatuses};
}

export const getPodReadinessGatesState = (pod: appModels.State): {nonExistingConditions: string[]; failedConditions: string[]} => {
export const getPodReadinessGatesState = (pod: appModels.State): {nonExistingConditions: string[]; notPassedConditions: string[]} => {
// if pod does not have readiness gates then return empty status
if (!pod.spec?.readinessGates?.length) {
return {
nonExistingConditions: [],
failedConditions: []
notPassedConditions: []
};
}

Expand Down Expand Up @@ -989,7 +990,7 @@ export const getPodReadinessGatesState = (pod: appModels.State): {nonExistingCon

return {
nonExistingConditions,
failedConditions
notPassedConditions: failedConditions
};
};

Expand Down

0 comments on commit bbc51fb

Please sign in to comment.