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: Fix inconsistent ordering of workflows with the list command. #7594

Merged
merged 1 commit into from
Jan 20, 2022

Conversation

dinever
Copy link
Member

@dinever dinever commented Jan 20, 2022

Fixes #7581

Hi, this PR fixes an issue where argo list -o name has inconsistent display order than argo list. The root cause is that we sort workflows based on CreationTimestamp and FinishedAt:

func (w Workflows) Less(i, j int) bool {
iStart := w[i].ObjectMeta.CreationTimestamp
iFinish := w[i].Status.FinishedAt
jStart := w[j].ObjectMeta.CreationTimestamp
jFinish := w[j].Status.FinishedAt
if iFinish.IsZero() && jFinish.IsZero() {
return !iStart.Before(&jStart)
}
if iFinish.IsZero() && !jFinish.IsZero() {
return true
}
if !iFinish.IsZero() && jFinish.IsZero() {
return false
}
return jFinish.Before(&iFinish)
}

So we need to make sure these two fields are included in the name-only field selectors as well, in order to have a consistent sort.

Before

Workflows have inconsistent display order with / without -o name
Screenshot from 2022-01-19 23-39-28

After

Workflows have consistent display order now
Screenshot from 2022-01-19 23-40-00

Thanks!

Signed-off-by: Peixuan Ding [email protected]

@alexec alexec merged commit bc27ada into argoproj:master Jan 20, 2022
@alexec
Copy link
Contributor

alexec commented Jan 20, 2022

Good work!

@dinever dinever deleted the fix-inconsistent-cli-list branch January 20, 2022 15:40
yriveiro pushed a commit to yriveiro/argo-workflows that referenced this pull request Jan 27, 2022
@alexec alexec mentioned this pull request Jan 27, 2022
4 tasks
alexec pushed a commit that referenced this pull request Jan 27, 2022
@sarabala1979 sarabala1979 mentioned this pull request Mar 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

argo CLI list command results not predictable with -o name flag
2 participants