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

Implement Step and Sidecar Overrides for TaskRun #4598

Merged
merged 1 commit into from
Mar 11, 2022

Conversation

lbernick
Copy link
Member

Changes

This implements TEP-0094: Configuring Resources at Runtime.
StepOverrides and SidecarOverrides were added to the API in a previous commit.
This commit allows them to override resource requirements specified in the Task spec.
The same merging strategy that is currently used for stepTemplate is also used for
step and sidecar overrides, except that only the resources field of the container is overridden,
and unlike with templates, the overrides take precedence over the Task spec.

Closes #4326.

Tested E2E locally. Happy to split into separate PRs if this would be helpful.

/kind feature

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 or deleted (only if no user facing changes)

Release Notes

[Feature] Implement Step and Sidecar Overrides for TaskRun

@tekton-robot tekton-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Feb 18, 2022
@lbernick
Copy link
Member Author

/assign wlynch

Feel free to unassign yourself if you don't have time to review! Just assigning you since you reviewed the TEP pretty thoroughly.

@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/v1beta1/merge.go 72.4% 76.9% 4.5
pkg/apis/pipeline/v1beta1/pipelinerun_types.go 86.0% 86.4% 0.3
pkg/pod/pod.go 89.5% 88.3% -1.1
pkg/reconciler/taskrun/taskrun.go 80.5% 79.8% -0.6
pkg/reconciler/taskrun/validate_resources.go 94.7% 95.5% 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/v1beta1/merge.go 72.4% 76.9% 4.5
pkg/apis/pipeline/v1beta1/pipelinerun_types.go 86.0% 86.4% 0.3
pkg/pod/pod.go 89.5% 88.3% -1.1
pkg/reconciler/taskrun/taskrun.go 80.5% 79.8% -0.6
pkg/reconciler/taskrun/validate_resources.go 94.7% 95.5% 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/v1beta1/merge.go 72.4% 82.8% 10.3
pkg/apis/pipeline/v1beta1/pipelinerun_types.go 86.0% 86.4% 0.3
pkg/pod/pod.go 89.5% 88.3% -1.1
pkg/reconciler/taskrun/taskrun.go 80.5% 79.8% -0.6
pkg/reconciler/taskrun/validate_resources.go 94.7% 95.5% 0.8

@afrittoli afrittoli added this to the Pipelines v0.34 milestone Feb 22, 2022
@lbernick
Copy link
Member Author

/hold
Decided to split into multiple PRs. First is #4617.

@tekton-robot tekton-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 24, 2022
@lbernick lbernick force-pushed the resource-overrides branch from 3bba8e8 to 140f26d Compare March 3, 2022 18:31
@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 Mar 3, 2022
@lbernick
Copy link
Member Author

lbernick commented Mar 3, 2022

/hold cancel

@tekton-robot tekton-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 3, 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/v1beta1/pipelinerun_types.go 86.0% 86.4% 0.3
pkg/pod/pod.go 89.5% 88.3% -1.1
pkg/reconciler/taskrun/taskrun.go 80.5% 79.8% -0.6
pkg/reconciler/taskrun/validate_resources.go 94.7% 95.5% 0.8

@ghost
Copy link

ghost commented Mar 3, 2022

/lgtm

@tekton-robot tekton-robot assigned ghost Mar 3, 2022
@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 3, 2022
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 @lbernick - looks good, left a few comments

pkg/reconciler/taskrun/validate_resources.go Outdated Show resolved Hide resolved
pkg/pod/pod_test.go Show resolved Hide resolved
@lbernick lbernick force-pushed the resource-overrides branch from 140f26d to 159f675 Compare March 4, 2022 15:10
@tekton-robot tekton-robot removed the lgtm Indicates that a PR is ready to be merged. label Mar 4, 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/v1beta1/pipelinerun_types.go 86.0% 86.4% 0.3
pkg/pod/pod.go 89.5% 88.3% -1.1
pkg/reconciler/taskrun/taskrun.go 80.5% 79.8% -0.6
pkg/reconciler/taskrun/validate_resources.go 94.7% 95.7% 1.1

@lbernick lbernick force-pushed the resource-overrides branch from 159f675 to 9da9add Compare March 4, 2022 15:24
@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/v1beta1/pipelinerun_types.go 86.0% 86.4% 0.3
pkg/pod/pod.go 89.5% 88.3% -1.1
pkg/reconciler/taskrun/taskrun.go 80.5% 79.8% -0.6
pkg/reconciler/taskrun/validate_resources.go 94.7% 95.7% 1.1

@lbernick
Copy link
Member Author

lbernick commented Mar 4, 2022

/test pull-tekton-pipeline-integration-tests

@lbernick
Copy link
Member Author

lbernick commented Mar 4, 2022

/test pull-tekton-pipeline-alpha-integration-tests

@lbernick
Copy link
Member Author

lbernick commented Mar 7, 2022

@jerop @sbwsg mind taking another look when you have time?

@ghost
Copy link

ghost commented Mar 7, 2022

/lgtm

Cheers @lbernick !

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 7, 2022
Copy link
Member

@wlynch wlynch left a comment

Choose a reason for hiding this comment

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

mostly lgtm! just a few nits regarding exporting funcs.

}}
for _, tc := range tcs {
t.Run(tc.name, func(t *testing.T) {
err := taskrun.ValidateOverrides(context.Background(), tc.ts, tc.trs)
Copy link
Member

Choose a reason for hiding this comment

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

Instead of exporting this func, can we move the test into the same package?

Copy link
Member Author

Choose a reason for hiding this comment

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

done. I left ValidateResolvedTaskResources exported as it's used in the pipelinerun reconciler to validate the param/resource bindings passed from the pipeline -> pipelinerun -> taskrun.

Comment on lines +141 to +148
steps, err = v1beta1.MergeStepsWithOverrides(steps, taskRun.Spec.StepOverrides)
if err != nil {
return nil, err
}
sidecars, err := v1beta1.MergeSidecarsWithOverrides(taskSpec.Sidecars, taskRun.Spec.SidecarOverrides)
if err != nil {
return nil, err
}
Copy link
Member

Choose a reason for hiding this comment

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

There's a TODO above to move the MergeStepsWithStepTemplate to this package (presumably to unexport it) - should we just do this from the get-go with these funcs? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

Discussed offline and reopened #1605 with comments.

This implements TEP-0094: Configuring Resources at Runtime.
StepOverrides and SidecarOverrides were added to the API in a previous commit.
This commit allows them to override resource requirements specified in the Task spec.
The same merging strategy that is currently used for stepTemplate is also used for
step and sidecar overrides, except that only the resources field of the container is overridden,
and unlike with templates, the overrides take precedence over the Task spec.
@lbernick lbernick force-pushed the resource-overrides branch from 9da9add to c6ffaf3 Compare March 8, 2022 20:01
@tekton-robot tekton-robot removed the lgtm Indicates that a PR is ready to be merged. label Mar 8, 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/v1beta1/pipelinerun_types.go 86.0% 86.4% 0.3
pkg/pod/pod.go 89.5% 88.3% -1.1
pkg/reconciler/taskrun/taskrun.go 80.5% 79.8% -0.6
pkg/reconciler/taskrun/validate_resources.go 94.7% 95.7% 1.1

@ghost
Copy link

ghost commented Mar 8, 2022

The workspace-in-sidecar example failed in the alpha integration run but is a known flake. Unfortunately no logs were printed but I think it's safe to retry.

/test pull-tekton-pipeline-alpha-integration-tests

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 8, 2022
@lbernick
Copy link
Member Author

lbernick commented Mar 9, 2022

@wlynch would you mind taking another look at this?

Copy link
Member

@wlynch wlynch 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
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: vdemeester, wlynch

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 Mar 11, 2022
@ghost
Copy link

ghost commented Mar 11, 2022

Integration run failed on a yaml example. Let's see if it repeats.

Workspace-in-sidecar failed in the alpha integration run, no logs because the step's container was waiting to start.

/test pull-tekton-pipeline-integration-tests

/test pull-tekton-pipeline-alpha-integration-tests

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.

Support specifying resource requests at the TaskRun level
6 participants