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

Add functions to merge step/sidecar overrides #4617

Merged
merged 1 commit into from
Mar 3, 2022

Conversation

lbernick
Copy link
Member

Changes

This commit adds methods to merge a slice of Step overrides with a slice of Steps.
This functionality is necessary for the full implementation of Step and Sidecar overrides.
It re-uses the merge process that is used to combine Steps and Step templates;
however, the Step is treated as the "template" so that the Step override takes precedence.
We do not attempt to validate the resource requirements of the resulting pod;
it's possible for the resulting pod to have resource requests > limits, which k8s will reject.
This is the same way we currently handle Step template.
Part 2 of #4326.
This is part of #4598, split out into its own PR.

/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

NONE

@tekton-robot tekton-robot added release-note-none Denotes a PR that doesnt merit a release note. kind/feature Categorizes issue or PR as related to a new feature. labels Feb 24, 2022
@tekton-robot tekton-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Feb 24, 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/merge.go 72.4% 82.8% 10.3

@lbernick
Copy link
Member Author

/test pull-tekton-pipeline-integration-tests

@jerop
Copy link
Member

jerop commented Feb 24, 2022

/assign

@@ -31,61 +31,111 @@ func MergeStepsWithStepTemplate(template *v1.Container, steps []Step) ([]Step, e
return steps, nil
}

// We need JSON bytes to generate a patch to merge the step containers
// onto the template container, so marshal the template.
templateAsJSON, err := json.Marshal(template)
Copy link
Member

Choose a reason for hiding this comment

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

Probably a bit of an optimization but can we pass the marshall object in mergeObject instead of the template string ? Before this merge we would marshall the template once and the use it in the loop. With this change, we will marshall the template for each steps, even though it never changes.

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! Note that the template doesn't change for StepTemplates, but it does change for StepOverrides, so I've provided two separate functions

@lbernick lbernick force-pushed the resource-overrides-merge branch from 9405cbb to b6bfb9c Compare February 25, 2022 15:11
@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% 81.8% 9.4

@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: vdemeester

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 Feb 25, 2022
@lbernick lbernick force-pushed the resource-overrides-merge branch from b6bfb9c to 8d51ab4 Compare February 25, 2022 15:25
@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% 81.8% 9.4

@lbernick lbernick force-pushed the resource-overrides-merge branch from 8d51ab4 to 1fe1d09 Compare February 25, 2022 15:54
@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% 81.8% 9.4

@lbernick lbernick force-pushed the resource-overrides-merge branch from 1fe1d09 to 2912e5b Compare March 3, 2022 15:26
@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% 81.8% 9.4

@lbernick
Copy link
Member Author

lbernick commented Mar 3, 2022

/test tekton-pipeline-unit-tests

@lbernick
Copy link
Member Author

lbernick commented Mar 3, 2022

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

This commit adds methods to merge a slice of Step overrides with a slice of Steps.
This functionality is necessary for the full implementation of Step and Sidecar overrides.
It re-uses the merge process that is used to combine Steps and Step templates;
however, the Step is treated as the "template" so that the Step override takes precedence.
We do not attempt to validate the resource requirements of the resulting pod;
it's possible for the resulting pod to have resource requests > limits, which k8s will reject.
This is the same way we currently handle Step template.
@lbernick lbernick force-pushed the resource-overrides-merge branch from 2912e5b to a424adb Compare March 3, 2022 16:19
@ghost
Copy link

ghost commented Mar 3, 2022

Awesome, cheers @lbernick !

/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
@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% 81.8% 9.4

@lbernick
Copy link
Member Author

lbernick commented Mar 3, 2022

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

1 similar comment
@lbernick
Copy link
Member Author

lbernick commented Mar 3, 2022

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

@tekton-robot tekton-robot merged commit c8a9e0b into tektoncd:main Mar 3, 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-none Denotes a PR that doesnt merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants