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

refactoring PipelineRunState to simplify logic for retrieving next tasks #3254

Merged
merged 1 commit into from
Oct 2, 2020

Conversation

pritidesai
Copy link
Member

@pritidesai pritidesai commented Sep 17, 2020

Changes

Introducing PipelineRunFacts as a combination of PipelineRunState, DAG Graph, and finally Graph. This simplifies function definitions in pipelinerun.go without having to pass graphs around.

This simplifies our implementation of retrieving next tasks, which will be further simplified in a separate PR if we decide to go this route. Also, this new struct would help simplify GetPipelineConditionStatus a whole lot (in a follow up PR).

/cc @bobcatfish

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

@tekton-robot tekton-robot added the release-note-none Denotes a PR that doesnt merit a release note. label Sep 17, 2020
@pritidesai
Copy link
Member Author

/kind cleanup

@tekton-robot tekton-robot added the kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. label Sep 17, 2020
@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/reconciler/pipelinerun/resources/pipelinerunstate.go 75.4% 69.7% -5.7

@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/reconciler/pipelinerun/resources/pipelinerunstate.go 75.4% 71.9% -3.5

@pritidesai
Copy link
Member Author

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/reconciler/pipelinerun/resources/pipelinerunstate.go 75.4% 71.9% -3.5

Adding a new function DAGExecutionQueue is bringing down the coverage here. We have this covered as part of pipelinerun_test.go but will add coverage here as well.

Introducing PipelineRunFacts as a combination of PipelineRunState, DAG
Graph, and finally Graph. This simplifies function definitions without having
to pass graphs to PipelineRunState attributes.
@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/reconciler/pipelinerun/resources/pipelinerunstate.go 75.4% 72.1% -3.3

Copy link
Member

@jerop jerop left a comment

Choose a reason for hiding this comment

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

thank you for this much-needed refactor @pritidesai 😀

Comment on lines +35 to +40
type PipelineRunFacts struct {
State PipelineRunState
TasksGraph *dag.Graph
FinalTasksGraph *dag.Graph
}

Copy link
Member

Choose a reason for hiding this comment

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

Given that PipelineRunState is a list of ResolvedPipelineRunTask...

type PipelineRunState []*ResolvedPipelineRunTask

...I was wondering if we could make that explicit by calling it ResolvedPipelineRunTasks then we can call this object PipelineRunState instead of PipelineRunFacts, what do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

@jerop I like it but given ResolvedPipelineRunTask is so long and differentiating it with the slice of ResolvedPipelineRunTask by just additional s might confuse readers.

Copy link
Member Author

Choose a reason for hiding this comment

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

we could rename ResolvedPipelineRunTask to ResolvedPipelineTask? 😜

Copy link
Member

Choose a reason for hiding this comment

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

yes yes, I like that especially given that we refer to it as PipelineTask instead of PipelineRunTask

Copy link
Member Author

Choose a reason for hiding this comment

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

thanks @jerop, will have that renaming going in a separate PR. Once this is merged, would like to get the refactoring of GetPipelineConditionStatus in 🙏

@afrittoli
Copy link
Member

Is this refactor solving the issue that #2821 was aiming to?
I waited on #2821 until the finally work was merged, and then it slipped behind other priorities :D

@pritidesai
Copy link
Member Author

pritidesai commented Sep 22, 2020

Is this refactor solving the issue that #2821 was aiming to?
I waited on #2821 until the finally work was merged, and then it slipped behind other priorities :D

This is the refactoring to simplify retrieving execution queue with DAG tasks, DAG tasks with when expressions, and finally tasks with minimal code changes. These changes in turn simplify GetPipelineConditionStatus.

@afrittoli
Copy link
Member

Is this refactor solving the issue that #2821 was aiming to?
I waited on #2821 until the finally work was merged, and then it slipped behind other priorities :D

This is the refactoring to simplify retrieving execution queue with DAG tasks, DAG tasks with when expressions, and finally tasks with minimal code changes. These changes in turn simplify GetPipelineConditionStatus.

Got it, thank you!

Combining PipelineRunState, DAG Graph, and finally Graph is the approach I was pursuing on #2821, but in my PR I did that in a different module, because the main goal there was to move handling of the DAG away from pipelinerun.go.
I'll try to figure out if this PR is compatible with that refactor, it may be that it works as an intermediate step towards it.

@pritidesai
Copy link
Member Author

thanks @afrittoli yes would be great to slowly get to the point where its easy to implement and review new functionalities to the existing scheduling (one very exciting near term feature coming in from @jerop as part of continueAfterSkip)

@@ -137,29 +132,53 @@ func (state PipelineRunState) checkTasksDone(d *dag.Graph) bool {
return true
}

func (facts *PipelineRunFacts) CheckDAGTasksDone() bool {
Copy link

Choose a reason for hiding this comment

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

nit: these three public funcs could use comments. Could be helpful for new devs not yet familiar with the distinction between Tasks and FinalTasks

@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sbwsg

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 Oct 1, 2020
Copy link
Member

@jerop jerop left a comment

Choose a reason for hiding this comment

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

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 2, 2020
@tekton-robot tekton-robot merged commit 78f5479 into tektoncd:master Oct 2, 2020
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/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm Indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesnt merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants