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

retrieving deps outside of dag.build #3583

Merged
merged 1 commit into from Dec 3, 2020

Conversation

pritidesai
Copy link
Member

@pritidesai pritidesai commented Dec 2, 2020

Changes

Adding an attribute function to PipelineTaskList to retrieve deps (thanks @bobcatfish for great suggestion), passing this deps to dag.Build function instead of retrieving deps from within that function.

This change was motivated while introducing task result consumption in finally tasks. Finally tasks can consume results from dag tasks but dag tasks are not part of the same graph/section and must not be added as part of deps of any finally tasks. This change allows reconciler (with the knowledge of dag tasks vs finally tasks) to manage deps while building a graph.

/kind misc

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

  • Includes tests (if functionality changed/added)
  • [] Includes docs (if user facing)
  • Commit messages follow commit message best practices
  • Release notes block has been filled in or deleted (only if no user facing changes)

See the contribution guide for more details.

Double check this list of stuff that's easy to miss:

Reviewer Notes

If API changes are included, additive changes must be approved by at least two OWNERS and backwards incompatible changes must be approved by more than 50% of the OWNERS, and they must first be added in a backwards compatible way.

Release Notes

NONE

Adding an attribute function to PipelineTaskList to retrieve deps
(thanks @bobcatfish for great suggestion), passing this deps to
Build function instead of retrieving it from within that function.

This change was motivated while introducing task result consumption in
finally tasks. Finally tasks can consume results from dag tasks but
dag tasks are not part of the same graph and must not be added as part of
deps of any finally tasks. This change allows reconciler (with the knowldege of
dag tasks vs finally tasks) to manage deps while building a graph.
@tekton-robot tekton-robot added release-note-none Denotes a PR that doesnt merit a release note. kind/misc Categorizes issue or PR as a miscellaneuous one. labels Dec 2, 2020
@tekton-robot tekton-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Dec 2, 2020
@pritidesai pritidesai mentioned this pull request Dec 2, 2020
4 tasks
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1alpha1/pipeline_types.go 69.0% 72.7% 3.8
pkg/apis/pipeline/v1beta1/pipeline_types.go 70.4% 72.4% 2.0
pkg/reconciler/pipeline/dag/dag.go 98.8% 98.8% -0.0

Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

This changes makes us do 2 loops instead of one right ?

@@ -67,17 +67,16 @@ func (g *Graph) addPipelineTask(t Task) (*Node, error) {
}

// Build returns a valid pipeline Graph. Returns error if the pipeline is invalid
func Build(tasks Tasks) (*Graph, error) {
func Build(tasks Tasks, deps map[string][]string) (*Graph, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Any reason to pass deps there as it comes from tasks ? we could just do

func Build(tasks Tasks) (*Graph, error) {
	deps = tasks.Deps()
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

@vdemeester that's what it currently does - maybe @pritidesai can add more info in the commit message to explain but the reason for this change is to be able to call Build with an empty dep list

in the case of finally tasks, we create 2 DAGs. when finally tasks depend on results from non-finally tasks, Deps() will return the non-finally Tasks (or will it error? im not sure). but in that case we don't want to build connections between the finally tasks and the non-finally tasks

making this change enables us to build a graph in both cases

another option might be to stop treating finally tasks as a graph but i have a strong feeling we will be adding more graph like features in future so im not sure we should do that now

Copy link
Collaborator

Choose a reason for hiding this comment

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

oh actually @pritidesai 's commit message does already explain this pretty well i think: 9716d32

Copy link
Member

Choose a reason for hiding this comment

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

oh I did not read the commit 😅

@bobcatfish
Copy link
Collaborator

nice!! one request, @pritidesai could you include some unit tests for the new function?

/approve

@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bobcatfish

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 3, 2020
@vdemeester
Copy link
Member

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Dec 3, 2020
@tekton-robot tekton-robot merged commit 431ea10 into tektoncd:master Dec 3, 2020
@pritidesai
Copy link
Member Author

nice!! one request, @pritidesai could you include some unit tests for the new function?

yup, creating a separate PR.

@pritidesai
Copy link
Member Author

nice!! one request, @pritidesai could you include some unit tests for the new function?

yup, creating a separate PR.

Please see PR #3597

@pritidesai pritidesai deleted the build-deps branch December 3, 2020 21:49
@bobcatfish
Copy link
Collaborator

hey @vdemeester just a comment that it would have been better to include the unit tests in the same PR (I think including tests and docs in PRs has been a great strategy for us; i want to make sure we don't end up having to play catch up with changes) - maybe it would be been clearer if i'd included a /block when i added the /approve?

@vdemeester
Copy link
Member

a /hold, yes 😉

@pritidesai
Copy link
Member Author

hey @vdemeester just a comment that it would have been better to include the unit tests in the same PR (I think including tests and docs in PRs has been a great strategy for us; i want to make sure we don't end up having to play catch up with changes) - maybe it would be been clearer if i'd included a /block when i added the /approve?

I think its my mistake, should have added unit tests in this PR instead of leaving it up to the reviewer. I was thinking the graphs we are testing in dag_test.go are sufficient which is indirectly testing Deps() but its always better to add unit tests for newly added functions. My apologies 🙏

@bobcatfish
Copy link
Collaborator

No worries @pritidesai !! :) ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/misc Categorizes issue or PR as a miscellaneuous one. lgtm Indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesnt merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants