Skip to content

Commit

Permalink
fix(ui): Cost Opt should only apply to live Workflows (argoproj#12170)
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Gilgur <[email protected]>
  • Loading branch information
agilgur5 authored Nov 9, 2023
1 parent 80cd2ec commit 873bacb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
3 changes: 2 additions & 1 deletion docs/cost-optimisation.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ A workflow (and for that matter, any Kubernetes resource) will incur a cost as l
The workflow controller memory and CPU needs to increase linearly with the number of pods and workflows you are currently running.
You should delete workflows once they are no longer needed, or enable a [Workflow Archive](workflow-archive.md) and you can still view them after they are removed from Kubernetes.
You should delete workflows once they are no longer needed.
You can enable the [Workflow Archive](workflow-archive.md) to continue viewing them after they are removed from Kubernetes.
Limit the total number of workflows using:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as React from 'react';
import {useContext, useEffect, useMemo, useState} from 'react';
import {RouteComponentProps} from 'react-router-dom';
import * as models from '../../../../models';
import {Workflow, WorkflowPhase, WorkflowPhases} from '../../../../models';
import {isArchivedWorkflow, Workflow, WorkflowPhase, WorkflowPhases} from '../../../../models';
import {uiUrl} from '../../../shared/base';

import {CostOptimisationNudge} from '../../../shared/components/cost-optimisation-nudge';
Expand Down Expand Up @@ -229,7 +229,7 @@ export function WorkflowsList({match, location, history}: RouteComponentProps<an
<>
{(counts.complete > 100 || counts.incomplete > 100) && (
<CostOptimisationNudge name='workflow-list'>
You have at least {counts.incomplete} incomplete, and {counts.complete} complete workflows. Reducing these amounts will reduce your costs.
You have at least {counts.incomplete} incomplete and {counts.complete} complete workflows. Reducing these amounts will reduce your costs.
</CostOptimisationNudge>
)}
<div className='argo-table-list'>
Expand Down Expand Up @@ -347,7 +347,12 @@ function nullSafeTimeFilter(createdAfter: Date, finishedBefore: Date, w: Workflo
function countsByCompleted(workflows?: Workflow[]) {
const counts = {complete: 0, incomplete: 0};
(workflows || []).forEach(wf => {
if (wf.metadata?.labels && wf.metadata?.labels[models.labels.completed] === 'true') {
// don't count archived workflows as this is for GC purposes
if (isArchivedWorkflow(wf)) {
return;
}

if (wf.metadata?.labels?.[models.labels.completed] === 'true') {
counts.complete++;
} else {
counts.incomplete++;
Expand Down
6 changes: 4 additions & 2 deletions ui/src/models/workflows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -548,11 +548,13 @@ export function isWorkflowInCluster(wf: Workflow): boolean {
return !wf.metadata.labels[archivalStatus] || wf.metadata.labels[archivalStatus] === 'Pending' || wf.metadata.labels[archivalStatus] === 'Archived';
}

export function isArchivedWorkflow(wf: Workflow): boolean {
export function isArchivedWorkflow(wf?: Workflow): boolean {
if (!wf) {
return false;
}
return wf.metadata.labels && (wf.metadata.labels[archivalStatus] === 'Archived' || wf.metadata.labels[archivalStatus] === 'Persisted');

const labelValue = wf.metadata?.labels?.[archivalStatus];
return labelValue === 'Archived' || labelValue === 'Persisted';
}

export type NodeType = 'Pod' | 'Container' | 'Steps' | 'StepGroup' | 'DAG' | 'Retry' | 'Skipped' | 'TaskGroup' | 'Suspend';
Expand Down

0 comments on commit 873bacb

Please sign in to comment.