Skip to content
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

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

Merged
merged 2 commits into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
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
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