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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge *Run's PodTemplate with Default 馃 #4057

Merged

Conversation

vdemeester
Copy link
Member

@vdemeester vdemeester commented Jun 23, 2021

Changes

Right, now when you specify a default pod template and also specify
pod template at pipelinerun/taskrun level. The default pod template is
getting overridden by the one at the pipelinerun/taskrun level.

This changes this behavior by only overriding the PodTemplate field
that are defined by the TaskRun and not the whole
PodTemplate. This means it is possible to define a NodeSelector
widely (through the default) without it being overriden when the user
sets a SecurityContext on his TaskRun.

This is also done on the PipelineRun PodTemplate.

Closes #3569

/cc @sbwsg @afrittoli @pritidesai @skaegi @bobcatfish

This probably need a bit more unit tests, but I think it's worth opening to discuss if the approach is correct (for each fields)

Signed-off-by: Vincent Demeester vdemeest@redhat.com

/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

TaskRun and PipelineRun's PodTemplate are now merge with the default PodTemplate. This means any field that is not specified in a TaskRun or PipelineRun's PodTemplate will come from the configured default PodTemplate (if defined).

@tekton-robot tekton-robot added 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. labels Jun 23, 2021
@vdemeester
Copy link
Member Author

This also probably needs some docs 馃檭
/hold

@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 Jun 23, 2021
@vdemeester
Copy link
Member Author

/retest

@vdemeester vdemeester force-pushed the 3569-merge-taskrun-podtemplate branch from a3567a8 to b6352d2 Compare June 24, 2021 07:33
@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_defaults.go 92.9% 92.3% -0.5
pkg/apis/pipeline/v1beta1/taskrun_defaults.go 100.0% 98.0% -2.0

@vdemeester
Copy link
Member Author

/retest

@vdemeester
Copy link
Member Author

/cc @piyush-garg

@ghost ghost added this to the Pipelines v0.26 milestone Jun 29, 2021
@ghost
Copy link

ghost commented Jun 29, 2021

This looks good from my perspective. 馃憤 /approve

Copy link
Member

@chmouel chmouel 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 Jun 30, 2021
@bobcatfish
Copy link
Collaborator

@vdemeester you mentioned adding some docs, is this something we can do before we merge? (maybe at https://github.com/tektoncd/pipeline/blob/main/docs/podtemplates.md)

Also looks like the coverage went down slightly - in both cases it looks like it's just one line per file not getting touched, maybe it's easy to add those to the test cases?

馃檹

Right, now when you specify a default pod template and also specify
pod template at pipelinerun/taskrun level. The default pod template is
getting overridden by the one at the pipelinerun/taskrun level.

This changes this behavior by only overriding the `PodTemplate` field
that are defined by the `TaskRun` and not the whole
`PodTemplate`. This means it is possible to define a `NodeSelector`
widely (through the default) without it being overriden when the user
sets a `SecurityContext` on his `TaskRun`.

This is also done on the `PipelineRun` PodTemplate.

Signed-off-by: Vincent Demeester <vdemeest@redhat.com>
@vdemeester vdemeester force-pushed the 3569-merge-taskrun-podtemplate branch from b6352d2 to 131bab1 Compare July 5, 2021 14:47
@tekton-robot tekton-robot removed the lgtm Indicates that a PR is ready to be merged. label Jul 5, 2021
@vdemeester
Copy link
Member Author

/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 Jul 5, 2021
@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_defaults.go 92.9% 92.3% -0.5

@ghost
Copy link

ghost commented Jul 7, 2021

Re-adding my approve.

/approve

@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 Jul 7, 2021
switch {
case defaultTpl == nil:
// No configured default, just return the template
return tpl
Copy link
Member

Choose a reason for hiding this comment

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

Could tpl be nil here? or not possible to have both defaultTpl and tpl to be nil at this point?

Copy link
Member

Choose a reason for hiding this comment

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

or don't bother to merge, just return tpl here irrespective of it being nil

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah if there is no default, we just return the taskrun template, be it nil or not 馃槢

default:
// Otherwise, merge fields
if tpl.NodeSelector == nil {
tpl.NodeSelector = defaultTpl.NodeSelector
Copy link
Member

Choose a reason for hiding this comment

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

do we need a check here if defaultTpl.NodeSelector is not nil and likewise for the rest of the fields?

Copy link
Member

Choose a reason for hiding this comment

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

or again just return default irrespective of it being nil

@pritidesai
Copy link
Member

/lgtm

thanks @vdemeester

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

tests seems flaky

/test tekton-pipeline-unit-tests
/test tekton-pipeline-build-tests
/test tekton-pipeline-alpha-integration-tests

@vdemeester
Copy link
Member Author

/retest

2 similar comments
@vdemeester
Copy link
Member Author

/retest

@vdemeester
Copy link
Member Author

/retest

@tekton-robot tekton-robot merged commit ea36b8c into tektoncd:main Jul 8, 2021
@vdemeester vdemeester deleted the 3569-merge-taskrun-podtemplate branch July 8, 2021 09:05
}
if tpl.HostNetwork == false && defaultTpl.HostNetwork == true {
tpl.HostNetwork = true
}
Copy link
Contributor

@Letty5411 Letty5411 Feb 24, 2022

Choose a reason for hiding this comment

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

Maybe sometimes the taskrun don't want to use hostnetwork, and set it 'false' in task template explicitly. If the value of global template is 'true', it will be set to 'true'.

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.

Default Podtemplate getting overriden with the pipelinerun and taskrun level podtemplate
6 participants