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

TEP-0111 - Propagating workspaces in taskruns #5081

Merged

Conversation

chitrangpatel
Copy link
Member

@chitrangpatel chitrangpatel commented Jul 5, 2022

The verbosity of writing specifications in Tekton Pipelines is a common pain point that creates difficulties in getting-started scenarios. In addition, the verbosity leads to long specifications that are error-prone, harder to maintain, and reach the etcd size limits for CRDs. Automatically propagating Workspaces will lead to better user experience. This addresses features proposed in TEP-0111. This PR addresses propagating workspaces in TaskRuns. A follow up PR is addressing propagating workspaces in PipelineRuns.

Changes

Submitter Checklist

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

  • Docs included if any changes are user facing
  • Tests included if any functionality added or changed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including
    functionality, content, code)
  • Release notes block below has been filled in
    (if there are no user facing changes, use release note "NONE")

Release Notes

Workspaces are propagated in embedded specifications without mutations.

@tekton-robot tekton-robot added the do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. label Jul 5, 2022
@tekton-robot tekton-robot requested review from dibyom and jerop July 5, 2022 18:47
@tekton-robot tekton-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jul 5, 2022
@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 86.2% 84.7% -1.5
pkg/reconciler/taskrun/taskrun.go 80.9% 80.9% -0.0
pkg/workspace/apply.go 100.0% 98.8% -1.2
pkg/workspace/validate.go 100.0% 96.3% -3.7

@chitrangpatel chitrangpatel force-pushed the TEP-0111-Propagating-Workspaces branch from b77584a to 2000cb1 Compare July 5, 2022 19:04
@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 86.2% 84.7% -1.5
pkg/reconciler/taskrun/taskrun.go 80.9% 80.9% -0.0
pkg/workspace/apply.go 100.0% 98.8% -1.2
pkg/workspace/validate.go 100.0% 96.3% -3.7

@tekton-robot tekton-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Jul 7, 2022
@chitrangpatel chitrangpatel force-pushed the TEP-0111-Propagating-Workspaces branch from 2000cb1 to 5fe2d48 Compare July 11, 2022 16:24
@tekton-robot tekton-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 11, 2022
@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 86.2% 84.7% -1.5
pkg/reconciler/taskrun/taskrun.go 80.9% 80.9% -0.0
pkg/workspace/apply.go 100.0% 98.8% -1.2
pkg/workspace/validate.go 100.0% 96.3% -3.7

@chitrangpatel
Copy link
Member Author

/retest

@jerop
Copy link
Member

jerop commented Jul 11, 2022

/kind feature

@tekton-robot tekton-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Jul 11, 2022
@jerop
Copy link
Member

jerop commented Jul 11, 2022

/retest

1 similar comment
@jerop
Copy link
Member

jerop commented Jul 12, 2022

/retest

@chitrangpatel
Copy link
Member Author

/test check-pr-has-kind-label

@tekton-robot
Copy link
Collaborator

@chitrangpatel: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test pull-tekton-pipeline-alpha-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
  • /test pull-tekton-pipeline-kind-alpha-integration-tests
  • /test pull-tekton-pipeline-kind-alpha-yaml-tests
  • /test pull-tekton-pipeline-kind-integration-tests
  • /test pull-tekton-pipeline-kind-yaml-tests

Use /test all to run the following jobs that were automatically triggered:

  • pull-tekton-pipeline-alpha-integration-tests
  • pull-tekton-pipeline-build-tests
  • pull-tekton-pipeline-go-coverage
  • pull-tekton-pipeline-integration-tests
  • pull-tekton-pipeline-unit-tests

In response to this:

/test check-pr-has-kind-label

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.

@chitrangpatel
Copy link
Member Author

/kind feature

@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 86.2% 84.7% -1.5
pkg/reconciler/taskrun/taskrun.go 80.9% 80.9% -0.0
pkg/workspace/apply.go 100.0% 98.8% -1.2
pkg/workspace/validate.go 100.0% 96.3% -3.7

@chitrangpatel
Copy link
Member Author

/retest

@jerop
Copy link
Member

jerop commented Jul 12, 2022

/assign @dibyom

@chitrangpatel chitrangpatel changed the title TEP-0111 - Propagating workspaces TEP-0111 - Propagating workspaces in task runs Sep 9, 2022
@chitrangpatel chitrangpatel changed the title TEP-0111 - Propagating workspaces in task runs TEP-0111 - Propagating workspaces in taskruns Sep 9, 2022
@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/v1/task_types.go 0.0% 96.4% 96.4
pkg/apis/pipeline/v1beta1/task_types.go 0.0% 87.5% 87.5
pkg/reconciler/taskrun/taskrun.go 80.7% 81.0% 0.3
pkg/substitution/substitution.go 62.2% 63.0% 0.8

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.

Thank you Chitrang for splitting into multiple PRs! it's a big help

pkg/reconciler/taskrun/taskrun.go Outdated Show resolved Hide resolved
pkg/substitution/substitution.go Outdated Show resolved Hide resolved
docs/tasks.md Outdated Show resolved Hide resolved
@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/v1/task_types.go 0.0% 96.4% 96.4
pkg/apis/pipeline/v1beta1/task_types.go 0.0% 87.5% 87.5
pkg/reconciler/taskrun/taskrun.go 80.7% 81.0% 0.3
pkg/substitution/substitution.go 62.2% 63.0% 0.8

@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/v1/task_types.go 0.0% 96.4% 96.4
pkg/apis/pipeline/v1beta1/task_types.go 0.0% 87.5% 87.5
pkg/reconciler/taskrun/taskrun.go 80.7% 81.0% 0.3

@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/v1/task_types.go 0.0% 96.4% 96.4
pkg/apis/pipeline/v1beta1/task_types.go 0.0% 87.5% 87.5
pkg/reconciler/taskrun/taskrun.go 80.7% 81.0% 0.3

Sidecars: []v1beta1.Sidecar{{
Name: "conflicting volume mount sidecar",
VolumeMounts: []corev1.VolumeMount{{
Name: "mount-path-conflicts",
Copy link
Member

Choose a reason for hiding this comment

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

it looks like this test case is for conflicting mount paths, can you rename to reflect what's being tested here?

Copy link
Member Author

Choose a reason for hiding this comment

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

No it wasn't. Its my mistake. Copy and pasting the above test and then modifying it lead to this confusion. I apologize. I will update it to better reflect the test its actually doing.

Copy link
Member Author

Choose a reason for hiding this comment

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

I made this into its own test to check the functionality I added in apply.go

}

// FindWorkspaceSubstitutionLocationsInTask returns a set of all the locations in the TaskSpec where we can apply substitutions.
func (ts *TaskSpec) FindWorkspaceSubstitutionLocationsInTask() sets.String {
Copy link
Member

Choose a reason for hiding this comment

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

Where is this function being used? It looks like this is functionality for replacing workspaces.foo.path syntax but I don't see it being used anywhere-- is this replacement happening as part of this PR?
If this function does need to be in this PR, I don't think it should be exported.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. Even though it is written in task_types, it might be being called from the PR handling propagated workspaces in pipelinerun.

Copy link
Member

Choose a reason for hiding this comment

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

In that case, how is this PR performing substitutions for task scripts/args containing $(workspaces.foo.path)?

Copy link
Member Author

Choose a reason for hiding this comment

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

This function was being called in the pipelinerun reconciler to parse the pipelineTask and identify which workspaces are being called. The reconciler then propagated those workspaces to the pipelineTasks by creating task bindings.

The taskRun reconciler (reconciler/taskrun/taskrun.go) does a similar thing and propagates workspaces to the taskSpec.
The substitutions happen the way they did before. i.e. via https://github.com/chitrangpatel/pipeline/blob/e302587a9dcbc7af8cc1475dfa24c3c35a6715f9/pkg/reconciler/pipelinerun/resources/apply.go#L173-L185.

@tekton-robot tekton-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Sep 12, 2022
@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/taskrun/taskrun.go 80.7% 81.0% 0.3

docs/tasks.md Outdated Show resolved Hide resolved
pkg/reconciler/taskrun/taskrun_test.go Show resolved Hide resolved
pkg/reconciler/taskrun/taskrun_test.go Show resolved Hide resolved
docs/taskruns.md Outdated Show resolved Hide resolved
docs/taskruns.md Show resolved Hide resolved
@tekton-robot tekton-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 12, 2022
@tekton-robot tekton-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 12, 2022
@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/taskrun/taskrun.go 80.7% 81.2% 0.5

This POC illustrates propagating workspaces defined at the `pipelinerun` stage and directly referred at the `spec`. There is no need to specify it in the `pipelinespec` followed by `tasks` and `taskspec`.
@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/taskrun/taskrun.go 80.7% 81.3% 0.6

@chitrangpatel
Copy link
Member Author

/retest

1 similar comment
@chitrangpatel
Copy link
Member 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.

/lgtm

@@ -2545,8 +2590,14 @@ spec:
Kind: "Task",
TaskSpec: &v1beta1.TaskSpec{Steps: simpleTask.Spec.Steps, Workspaces: simpleTask.Spec.Workspaces},
}
taskSpec := updateTaskSpecParamsContextsResults(context.Background(), taskRun, rtr)
pod, err := r.createPod(testAssets.Ctx, taskSpec, taskRun, rtr)
ctx := config.EnableAlphaAPIFields(context.Background())
Copy link
Member

Choose a reason for hiding this comment

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

would you mind creating an issue to refactor these tests to call Reconcile rather than all of these helpers?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure. I can do that.

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 14, 2022
@tekton-robot tekton-robot merged commit 0b3d1e7 into tektoncd:main Sep 14, 2022
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/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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.

5 participants