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(controller): Support any() and all() for TaskGroup in depends logic. Closes #3405 #3964

Merged
merged 3 commits into from Dec 3, 2020

Conversation

markterm
Copy link
Contributor

@markterm markterm commented Sep 8, 2020

If a DAG task depends on a task that uses withItems, then can depend on any or all of the children being in a status.

Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this is a chore.
  • The title of the PR is (a) conventional, (b) states what changed, and (c) suffixes the related issues number. E.g. "fix(controller): Updates such and such. Fixes #1234".
  • I've signed the CLA.
  • I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
  • My builds are green. Try syncing with master if they are not.
  • My organization is added to USERS.md.

@markterm markterm changed the title 3405 any all depends logic feat(controller): Support any() and all() for TaskGroup in depends logic Sep 8, 2020
@markterm markterm changed the title feat(controller): Support any() and all() for TaskGroup in depends logic feat(controller): Support any() and all() for TaskGroup in depends logic. Closes #3405 Sep 8, 2020
@simster7 simster7 self-assigned this Sep 8, 2020
@markterm
Copy link
Contributor Author

markterm commented Sep 8, 2020

FYI @simster7

@simster7
Copy link
Member

simster7 commented Sep 8, 2020

Thanks, will take a look at this over the coming days

@markterm
Copy link
Contributor Author

Just a little nudge @simster7 ;)

@simster7
Copy link
Member

Hi @mark9white, thanks for the nudge and sorry for the delay. I'll take a look today

@simster7
Copy link
Member

Hey @mark9white. Thanks for submitting this change and sorry for the delay. We agreed to support this feature, but we want to consider a different syntax.

Having any(task.Succeeded), doesn't make much sense as: (1) there is nothing that distinguishes whether task actually expanded or not, (2) overloads the meaning of task.Succeeded: if it's inside any(...) then it refers to the expanded tasks, while if it's not it refers to the parent task, and (3) frankly it doesn't make much sense.

We want to experiment a bit with possible syntaxes. Ideas that came around include:

  • Having an "expander" such as task.ExpandedTasks resolve to a list of individual tasks statuses. We can then leverage expr to evaluate on them (such as "Succeeded" in task.ExpandedTasks)
  • Having dedicated boolean attributes (such as task.AnySucceeded, task.AllFailed)
  • Others?

Thoughts?

@markterm
Copy link
Contributor Author

Thanks for taking a look. I think dedicated boolean attributes as you suggest, eg task.AnySucceeded, would be easiest for the users to understand and use. I could change the PR implementation to that?

@simster7
Copy link
Member

Sure sounds good. I'm thinking that we only need to have task.AnySucceeded since task.AllFailed can be inferred from it:

task.AllFailed = task.Failed && !task.AnySucceeded

What do you think? Are there any more than we might need?

@markterm
Copy link
Contributor Author

I think if we want to minimise the surface area then task.AnySucceeded would be enough for most requirements, and I'd be fine with just implementing that.

However if we want to provide full flexibility then I would add all the permutations. For example, it's not exactly possible to calculated all failed as you suggest - eg the case where one was skipped, one failed and none succeeded. And having a direct AllFailed makes it easier to read Argo workflows than combinations of other conditions.

@simster7
Copy link
Member

Sure let's start with AnySucceeded and AllFailed. Please add validation such that if a user tries to use these variables in a task which does not expand, they will get an error

@alexec alexec self-assigned this Oct 8, 2020
@alexec
Copy link
Contributor

alexec commented Oct 8, 2020

@mark9white let me know if you need any help with this.

@markterm
Copy link
Contributor Author

markterm commented Oct 8, 2020

@alexec Thanks, I should be able to get to it in a couple of weeks ..

alexec
alexec previously requested changes Oct 19, 2020
Copy link
Contributor

@alexec alexec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested

@markterm markterm force-pushed the 3405-any-all-depends-logic branch 2 times, most recently from f89abcd to 5ae3db2 Compare October 30, 2020 18:03
@markterm
Copy link
Contributor Author

markterm commented Nov 5, 2020

@simster7 @alexec FYI I have made the requested changes.

Makefile Outdated
@@ -47,7 +47,7 @@ CONTROLLER_IMAGE_FILE := dist/controller-image.marker

# perform static compilation
STATIC_BUILD ?= true
STATIC_FILES ?= true
STATIC_FILES ?= false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@simster7 simster7 self-assigned this Nov 5, 2020
Copy link
Member

@simster7 simster7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gave this a very quick first pass

type DependencyType int

const (
TaskDependency DependencyType = 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
TaskDependency DependencyType = 0
DependencyTypeTaskDependency DependencyType = iota

See: https://yourbasic.org/golang/iota/

Only needed for the first item

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

for _, matchGroup := range matches {
// We have matched a taskName.TaskResult
if matchGroup[2] != -1 {
match := depends[matchGroup[2]:matchGroup[3]]
split := strings.Split(match, ".")
dependencies[split[0]] = true
if split[1] == "AnySucceeded" || split[1] == "AllFailed" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use raw strings instead of our const variables?

@@ -44,7 +44,7 @@ type dagContext struct {

// dependencies is a list of all the tasks a specific task depends on. Because dependencies are computed using regex
// and regex is expensive, we cache the results so that they are only computed once per operation
dependencies map[string][]string
dependencies map[string]map[string]common.DependencyType
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm almost surely wrong, but I didn't see a place where we actually use the value of the inner map (i.e. common.DependencyType). Can you explain why it's necessary, point me where it's used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue is that dagValidationContext needs the inner map, and was getting passed in as a dagContext, so I modified dagContext to keep them matching. This wasn't ideal, I've fixed it up.

@markterm markterm force-pushed the 3405-any-all-depends-logic branch 3 times, most recently from be79772 to c6fc802 Compare November 9, 2020 17:54
@markterm
Copy link
Contributor Author

I don't think the build failure is related to my change.

@markterm markterm force-pushed the 3405-any-all-depends-logic branch 2 times, most recently from 5ebd1bb to 4bd2e0e Compare November 10, 2020 10:09
@markterm
Copy link
Contributor Author

@alexec @simster7 Am checking next steps here?

@alexec
Copy link
Contributor

alexec commented Dec 1, 2020

@simster7 do you have anymore feedback on this please?

Copy link
Member

@simster7 simster7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay. This LGTM, I just want @jessesuen to approve of the syntax. I will bring this up with him tomorrow

@simster7
Copy link
Member

simster7 commented Dec 1, 2020

@markterm Can you merger/rebase this with master please?

… depends logic. Closes argoproj#3405

Signed-off-by: Mark White <mark@markwhite.com>
@markterm
Copy link
Contributor Author

markterm commented Dec 1, 2020

@simster7 done

@simster7
Copy link
Member

simster7 commented Dec 3, 2020

@markterm Could you check this box?

image

This way we can merge this branch with master on our own to merge it faster

@markterm
Copy link
Contributor Author

markterm commented Dec 3, 2020

I don't have that option, so I've given access to the repo which will hopefully have the same effect. I've also triggered a branch update with master.

@simster7 simster7 merged commit 1212df4 into argoproj:master Dec 3, 2020
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.

None yet

3 participants