Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ui): soften readiness gate failure message (#13972)
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
crenshaw-dev committed Jun 15, 2023
1 parent f63b856 commit 6403beb
Showing 4 changed files with 26 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -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');
@@ -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);
}
@@ -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 => (
Original file line number Diff line number Diff line change
@@ -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;
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 && (
7 changes: 4 additions & 3 deletions ui/src/app/applications/components/utils.tsx
Original file line number Diff line number Diff line change
@@ -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: []
};
}

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

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

0 comments on commit 6403beb

Please sign in to comment.