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

Refactor ResolvedPipelineTask and remove redundant fields #6649

Merged

Conversation

EmmaMunley
Copy link
Contributor

@EmmaMunley EmmaMunley commented May 11, 2023

Changes

Currently, PipelineRun resolution code can be difficult to understand. This commit removes some of the redundant fields in ResolvedPipelineTask including the singular version of: TaskRun, TaskRunName, ObjectRun, ObjectRunName so that only the list of TaskRuns, TaskRunNames, ObjectRuns, ObjectRunNames can be used regardless if the PipelineTask is matrixed or not. This also streamlines the codebase by removing the switch statements used throughout. This partially addresses Issue #6628.

/kind cleanup

Submitter Checklist

As the author of this PR, please check off the items in this checklist:

  • Has Docs if any changes are user facing, including updates to minimum requirements e.g. Kubernetes version bumps
  • Has Tests included if any functionality added or changed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including functionality, content, code)
  • Has a kind label. You can add one by adding a comment on this PR that contains /kind <type>. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tep
  • Release notes block below has been updated with any user facing changes (API changes, bug fixes, changes requiring upgrade notices or deprecation warnings). See some examples of good release notes.
  • Release notes contains the string "action required" if the change requires additional action from users switching to the new release

Release Notes

None

@tekton-robot tekton-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels May 11, 2023
@tekton-robot tekton-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label May 11, 2023
@jerop jerop self-assigned this May 11, 2023
@EmmaMunley EmmaMunley force-pushed the refactor-resolved-pipeline-task branch from c85b77b to 8a5774c Compare May 11, 2023 17:46
@tekton-robot tekton-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 11, 2023
@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/pipelinerun.go 89.2% 90.3% 1.1
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.7% 96.6% -0.1
pkg/reconciler/pipelinerun/resources/pipelinerunstate.go 99.5% 99.5% -0.0

@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 89.2% 90.3% 1.1
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.7% 96.6% -0.1
pkg/reconciler/pipelinerun/resources/pipelinerunstate.go 99.5% 99.5% -0.0

@EmmaMunley EmmaMunley force-pushed the refactor-resolved-pipeline-task branch from 8a5774c to 1127c9e Compare May 11, 2023 18:20
@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/pipelinerun.go 89.2% 90.3% 1.1
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.7% 96.6% -0.1
pkg/reconciler/pipelinerun/resources/pipelinerunstate.go 99.5% 99.5% -0.0

@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 89.2% 90.3% 1.1
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.7% 96.6% -0.1
pkg/reconciler/pipelinerun/resources/pipelinerunstate.go 99.5% 99.5% -0.0

@EmmaMunley
Copy link
Contributor Author

/assign @lbernick

pkg/reconciler/pipelinerun/resources/pipelinerunstate.go Outdated Show resolved Hide resolved
pkg/reconciler/pipelinerun/resources/pipelinerunstate.go Outdated Show resolved Hide resolved
pkg/reconciler/pipelinerun/resources/pipelinerunstate.go Outdated Show resolved Hide resolved
pkg/reconciler/pipelinerun/resources/pipelinerunstate.go Outdated Show resolved Hide resolved
@EmmaMunley EmmaMunley force-pushed the refactor-resolved-pipeline-task branch from 1127c9e to 6f03a8e Compare May 12, 2023 16:48
Copy link
Contributor Author

@EmmaMunley EmmaMunley left a comment

Choose a reason for hiding this comment

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

Thanks for the review @lbernick. Updated with comments below.

@@ -112,9 +112,9 @@ func (state PipelineRunState) ToMap() map[string]*ResolvedPipelineTask {
// IsBeforeFirstTaskRun returns true if the PipelineRun has not yet started its first TaskRun
func (state PipelineRunState) IsBeforeFirstTaskRun() bool {
for _, t := range state {
if t.IsCustomTask() && t.RunObject != nil {
if t.IsCustomTask() && len(t.RunObjects) > 0 {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated and added test coverage for matrixed runs.

@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/pipelinerun.go 89.2% 90.3% 1.1
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.7% 94.4% -2.3
pkg/reconciler/pipelinerun/resources/pipelinerunstate.go 99.5% 98.9% -0.5
pkg/reconciler/pipelinerun/resources/resultrefresolution.go 91.8% 91.2% -0.7

@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 89.2% 90.3% 1.1
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.7% 94.4% -2.3
pkg/reconciler/pipelinerun/resources/pipelinerunstate.go 99.5% 98.9% -0.5
pkg/reconciler/pipelinerun/resources/resultrefresolution.go 91.8% 91.2% -0.7

@EmmaMunley
Copy link
Contributor Author

EmmaMunley commented May 12, 2023

/retest
This appears to be a flake. Issue filed here: #6655

@tekton-robot
Copy link
Collaborator

@EmmaMunley: The /retest command does not accept any targets.
The following commands are available to trigger required jobs:

  • /test pull-tekton-pipeline-alpha-integration-tests
  • /test pull-tekton-pipeline-beta-integration-tests
  • /test pull-tekton-pipeline-build-tests
  • /test pull-tekton-pipeline-integration-tests
  • /test tekton-pipeline-unit-tests

The following commands are available to trigger optional jobs:

  • /test pull-tekton-pipeline-go-coverage

Use /test all to run all jobs.

In response to this:

/retest This appears to be a flake. Issue filed here: #6655

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@EmmaMunley
Copy link
Contributor Author

/retest

Copy link
Member

@lbernick lbernick left a comment

Choose a reason for hiding this comment

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

@EmmaMunley thanks for the updates! would you mind pulling the bug fixes (e.g. isBeforeFirstTaskRun) into a separate PR?

@EmmaMunley EmmaMunley force-pushed the refactor-resolved-pipeline-task branch from 6f03a8e to 3fba1b8 Compare May 15, 2023 14:52
@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/pipelinerun.go 89.2% 90.3% 1.1
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.7% 94.4% -2.3
pkg/reconciler/pipelinerun/resources/pipelinerunstate.go 99.5% 98.9% -0.5
pkg/reconciler/pipelinerun/resources/resultrefresolution.go 91.8% 91.2% -0.7

@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 89.2% 90.3% 1.1
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.7% 94.4% -2.3
pkg/reconciler/pipelinerun/resources/pipelinerunstate.go 99.5% 98.9% -0.5
pkg/reconciler/pipelinerun/resources/resultrefresolution.go 91.8% 91.2% -0.7

@EmmaMunley
Copy link
Contributor Author

/retest
#6680

@EmmaMunley EmmaMunley force-pushed the refactor-resolved-pipeline-task branch from 350e429 to 38c2e08 Compare May 18, 2023 16:02
@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/pipelinerun.go 89.2% 90.3% 1.1
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.6% 97.3% 0.7
pkg/reconciler/pipelinerun/resources/pipelinerunstate.go 99.5% 99.5% -0.0
pkg/reconciler/pipelinerun/resources/resultrefresolution.go 91.8% 92.3% 0.5

@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 89.2% 90.3% 1.1
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.6% 97.3% 0.7
pkg/reconciler/pipelinerun/resources/pipelinerunstate.go 99.5% 99.5% -0.0
pkg/reconciler/pipelinerun/resources/resultrefresolution.go 91.8% 92.3% 0.5

@EmmaMunley EmmaMunley force-pushed the refactor-resolved-pipeline-task branch from 38c2e08 to a791bad Compare May 18, 2023 17:12
@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/pipelinerun.go 89.2% 90.3% 1.1
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.6% 97.0% 0.4
pkg/reconciler/pipelinerun/resources/pipelinerunstate.go 99.5% 99.5% -0.0
pkg/reconciler/pipelinerun/resources/resultrefresolution.go 91.8% 92.3% 0.5

@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 89.2% 90.3% 1.1
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.6% 97.0% 0.4
pkg/reconciler/pipelinerun/resources/pipelinerunstate.go 99.5% 99.5% -0.0
pkg/reconciler/pipelinerun/resources/resultrefresolution.go 91.8% 92.3% 0.5

@tekton-robot tekton-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 19, 2023
@EmmaMunley EmmaMunley force-pushed the refactor-resolved-pipeline-task branch from a791bad to 156dc98 Compare May 19, 2023 12:37
@tekton-robot tekton-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 19, 2023
@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/pipelinerun.go 89.2% 90.3% 1.1
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.6% 97.0% 0.4
pkg/reconciler/pipelinerun/resources/pipelinerunstate.go 99.5% 99.5% -0.0
pkg/reconciler/pipelinerun/resources/resultrefresolution.go 91.8% 92.3% 0.5

@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 89.2% 90.3% 1.1
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.6% 97.0% 0.4
pkg/reconciler/pipelinerun/resources/pipelinerunstate.go 99.5% 99.5% -0.0
pkg/reconciler/pipelinerun/resources/resultrefresolution.go 91.8% 92.3% 0.5

@EmmaMunley EmmaMunley requested a review from jerop May 19, 2023 15:06
Copy link
Member

@Yongxuanzhang Yongxuanzhang left a comment

Choose a reason for hiding this comment

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

In general lgtm, thanks for improving the code! There are lots of nice improvements

Currently, PipelineRun resolution code can be difficult to understand. This commit removes some of the redundant fields in  ResolvedPipelineTask including the singular version of: TaskRun, TaskRunName, ObjectRun, ObjectRunName so that only the list of TaskRuns, TaskRunNames,  ObjectRuns, ObjectRunNames can be used  regardless if the PipelineTask is matrixed or not. This also streamlines the codebase by removing the switch statements used throughout. This partially addresses Issue tektoncd#6628.
@EmmaMunley EmmaMunley force-pushed the refactor-resolved-pipeline-task branch from 156dc98 to 88ed934 Compare May 22, 2023 15:19
@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/pipelinerun.go 89.2% 90.3% 1.1
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.6% 97.0% 0.4
pkg/reconciler/pipelinerun/resources/pipelinerunstate.go 99.5% 99.5% -0.0
pkg/reconciler/pipelinerun/resources/resultrefresolution.go 91.8% 92.3% 0.5

@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 89.2% 90.3% 1.1
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.6% 97.0% 0.4
pkg/reconciler/pipelinerun/resources/pipelinerunstate.go 99.5% 99.5% -0.0
pkg/reconciler/pipelinerun/resources/resultrefresolution.go 91.8% 92.3% 0.5

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.

Thanks @EmmaMunley!

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label May 22, 2023
@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jerop, lbernick, Yongxuanzhang

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 merged commit 19af21c into tektoncd:main May 22, 2023
@EmmaMunley EmmaMunley deleted the refactor-resolved-pipeline-task branch May 22, 2023 17:28
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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants