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

feat: Expose OPA warnings to ArgoCD UI #11856

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
20 changes: 20 additions & 0 deletions ui/src/app/applications/components/utils.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,14 @@ test('OperationState.Sync OK', () => {
expect(tree).toMatchSnapshot();
});

test('OperationState.Sync warning', () => {
const tree = renderer
.create(<OperationState app={{metadata: {}, status: {operationState: {operation: {sync: {}}, phase: OperationPhases.Warning}}} as Application} />)
.toJSON();

expect(tree).toMatchSnapshot();
});

test('OperationState.Sync error', () => {
const tree = renderer.create(<OperationState app={{metadata: {}, status: {operationState: {operation: {sync: {}}, phase: OperationPhases.Error}}} as Application} />).toJSON();

Expand Down Expand Up @@ -212,6 +220,12 @@ test('ResourceResultIcon.SyncFailed', () => {
expect(tree).toMatchSnapshot();
});

test('ResourceResultIcon.SyncedWithWarning', () => {
const tree = renderer.create(<ResourceResultIcon resource={{status: ResultCodes.SyncedWithWarning} as ResourceResult} />).toJSON();

expect(tree).toMatchSnapshot();
});

test('ResourceResultIcon.Hook.Running', () => {
const tree = renderer
.create(
Expand Down Expand Up @@ -253,3 +267,9 @@ test('ResourceResultIcon.Hook.Terminating', () => {

expect(tree).toMatchSnapshot();
});

test('ResourceResultIcon.Hook.Warning', () => {
const tree = renderer.create(<ResourceResultIcon resource={{hookType: 'Sync', hookPhase: OperationPhases.Warning} as ResourceResult} />).toJSON();

expect(tree).toMatchSnapshot();
});
16 changes: 15 additions & 1 deletion ui/src/app/applications/components/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ export const OperationPhaseIcon = ({app}: {app: appModels.Application}) => {
className = 'fa fa-check-circle';
color = COLORS.operation.success;
break;
case appModels.OperationPhases.Warning:
className = 'fa fa-check-circle';
color = COLORS.operation.warning;
break;
case appModels.OperationPhases.Error:
className = 'fa fa-times-circle';
color = COLORS.operation.error;
Expand Down Expand Up @@ -764,6 +768,10 @@ export const ResourceResultIcon = ({resource}: {resource: appModels.ResourceResu
case appModels.ResultCodes.PruneSkipped:
icon = 'fa-heart';
break;
case appModels.ResultCodes.SyncedWithWarning:
color = COLORS.sync_result.SyncedWithWarning;
icon = 'fa-heart-broken';
break;
}
let title: string = resource.message;
if (resource.message) {
Expand Down Expand Up @@ -794,6 +802,10 @@ export const ResourceResultIcon = ({resource}: {resource: appModels.ResourceResu
color = COLORS.operation.terminating;
className = 'fa fa-circle-notch fa-spin';
break;
case appModels.OperationPhases.Warning:
color = COLORS.operation.warning;
className = 'fa fa-heart-broken';
break;
}
let title: string = resource.message;
if (resource.message) {
Expand Down Expand Up @@ -867,6 +879,8 @@ const getOperationStateTitle = (app: appModels.Application) => {
return 'Sync OK';
case 'Terminating':
return 'Terminated';
case 'Warning':
return 'Sync warning';
}
}
return 'Unknown';
Expand All @@ -877,7 +891,7 @@ export const OperationState = ({app, quiet}: {app: appModels.Application; quiet?
if (appOperationState === undefined) {
return <React.Fragment />;
}
if (quiet && [appModels.OperationPhases.Running, appModels.OperationPhases.Failed, appModels.OperationPhases.Error].indexOf(appOperationState.phase) === -1) {
if (quiet && [appModels.OperationPhases.Running, appModels.OperationPhases.Failed, appModels.OperationPhases.Error, appModels.OperationPhases.Warning].indexOf(appOperationState.phase) === -1) {
return <React.Fragment />;
}

Expand Down
9 changes: 6 additions & 3 deletions ui/src/app/shared/components/colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,21 @@ export const COLORS = {
failed: ARGO_FAILED_COLOR,
running: ARGO_RUNNING_COLOR,
success: ARGO_SUCCESS_COLOR,
terminating: ARGO_TERMINATING_COLOR
terminating: ARGO_TERMINATING_COLOR,
warning: ARGO_WARNING_COLOR
},
sync: {
synced: ARGO_SUCCESS_COLOR,
out_of_sync: ARGO_WARNING_COLOR,
unknown: ARGO_GRAY4_COLOR
unknown: ARGO_GRAY4_COLOR,
SyncedWithWarning: ARGO_WARNING_COLOR
},
sync_result: {
failed: ARGO_FAILED_COLOR,
synced: ARGO_SUCCESS_COLOR,
pruned: ARGO_GRAY4_COLOR,
unknown: ARGO_GRAY4_COLOR
unknown: ARGO_GRAY4_COLOR,
SyncedWithWarning: ARGO_WARNING_COLOR
},
sync_window: {
deny: ARGO_FAILED_COLOR,
Expand Down
10 changes: 6 additions & 4 deletions ui/src/app/shared/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,15 @@ export interface Operation {
initiatedBy: OperationInitiator;
}

export type OperationPhase = 'Running' | 'Error' | 'Failed' | 'Succeeded' | 'Terminating';
export type OperationPhase = 'Running' | 'Error' | 'Failed' | 'Succeeded' | 'Terminating' | 'Warning';

export const OperationPhases = {
Running: 'Running' as OperationPhase,
Failed: 'Failed' as OperationPhase,
Error: 'Error' as OperationPhase,
Succeeded: 'Succeeded' as OperationPhase,
Terminating: 'Terminating' as OperationPhase
Terminating: 'Terminating' as OperationPhase,
Warning: 'Warning' as OperationPhase
};

/**
Expand Down Expand Up @@ -99,13 +100,14 @@ export interface SyncOperationResult {
revision: string;
}

export type ResultCode = 'Synced' | 'SyncFailed' | 'Pruned' | 'PruneSkipped';
export type ResultCode = 'Synced' | 'SyncFailed' | 'Pruned' | 'PruneSkipped' | 'SyncedWithWarning';

export const ResultCodes = {
Synced: 'Synced',
SyncFailed: 'SyncFailed',
Pruned: 'Pruned',
PruneSkipped: 'PruneSkipped'
PruneSkipped: 'PruneSkipped',
SyncedWithWarning: 'SyncedWithWarning'
};

export interface ResourceResult {
Expand Down