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

Fix docs and remove redundant code for LimitRanges #5351

Merged
merged 1 commit into from
Sep 7, 2022

Conversation

lbernick
Copy link
Member

Changes

Prior to this commit, LimitRange transformer behavior did not match our documentation.
Our documentation stated that Tekton adjusts compute resources of containers to fit within
LimitRange minimum requests and maximum limits. This is not true. Instead, Tekton divides LimitRange
defaultRequests among Step containers, and considers the minimum only if the defaultRequest divided
by the number of Steps would be less than the minimum.

In addition, the LimitRange transformer does several things that would be done by Kubernetes anyway,
which are removed by this commit.
When a LimitRange is created, Kubernetes automatically sets defaults and defaultRequests to the max
if a user did not specify them. Kubernetes will automatically apply these defaults and defaultRequests
to any pods created. Therefore, there is no need for Tekton to set container limits to the default limits
(or in fact, to consider limits at all). There's also no need for Tekton to consider defaults/defaultRequests
for Sidecars and init containers, as we are happy to accept Kubernetes' default behavior here.
The only resource requirements we need to modify are to split a LimitRange's defaultRequests among Steps that
don't specify requests, so all other LimitRange-based transformations are removed in this commit.

Note that Tekton makes no guarantees that a TaskRun's pod will be valid (i.e. requests <= limits).
If a user configures a TaskRun in a way that is inconsistent with any LimitRanges, we allow Kubernetes
to reject the resulting pod.

/kind bug

Submitter Checklist

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

  • Has Docs included if any changes are user facing
  • 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)
  • n/a Release notes contains the string "action required" if the change requires additional action from users switching to the new release

Release Notes

[Bug fix] Clarify limitrange documentation and remove functionality that's provided by k8s anyway

Prior to this commit, LimitRange transformer behavior did not match our documentation.
Our documentation stated that Tekton adjusts compute resources of containers to fit within
LimitRange minimum requests and maximum limits. This is not true. Instead, Tekton divides LimitRange
defaultRequests among Step containers, and considers the minimum only if the defaultRequest divided
by the number of Steps would be less than the minimum.

In addition, the LimitRange transformer does several things that would be done by Kubernetes anyway,
which are removed by this commit.
When a LimitRange is created, Kubernetes automatically sets defaults and defaultRequests to the max
if a user did not specify them. Kubernetes will automatically apply these defaults and defaultRequests
to any pods created. Therefore, there is no need for Tekton to set container limits to the default limits
(or in fact, to consider limits at all). There's also no need for Tekton to consider defaults/defaultRequests
for Sidecars and init containers, as we are happy to accept Kubernetes' default behavior here.
The only resource requirements we need to modify are to split a LimitRange's defaultRequests among Steps that
don't specify requests, so all other LimitRange-based transformations are removed in this commit.

Note that Tekton makes no guarantees that a TaskRun's pod will be valid (i.e. requests <= limits).
If a user configures a TaskRun in a way that is inconsistent with any LimitRanges, we allow Kubernetes
to reject the resulting pod.
@tekton-robot tekton-robot added kind/bug Categorizes issue or PR as related to a bug. release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Aug 19, 2022
@tekton-robot tekton-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Aug 19, 2022
@lbernick
Copy link
Member Author

Closes #5278

@lbernick lbernick linked an issue Aug 19, 2022 that may be closed by this pull request
@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/internal/computeresources/transformer.go 91.9% 85.7% -6.2

Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

Instead, Tekton divides LimitRange defaultRequests among Step containers, and considers the minimum only if the defaultRequest divided by the number of Steps would be less than the minimum.

This one is important one in my view and shouldn't be removed. We do not need to do anything smart, but we did add this "support" to, at least, "try" to consume as little as possible, while still being valid.

We've been up and down with this support, but I am not sure reverting some of our decision is the best move — mainly, as of today, I "feel" we are doing probably the least amount of work that we could/should do — but it could make sense to be even less smart and just heavily document how to use LimitRange with Tekton.

I think one of the main "trick" here is that end-users might want to use the same LimitRange for Tekton workloads and their own workloads, which might not work for the best.

@lbernick
Copy link
Member Author

@vdemeester I'm a bit confused-- this PR isn't intended to cause any changes in behavior; I think I might have just misunderstood what the limitrange transformer does when I wrote these docs. I agree we don't want to be repeatedly changing this behavior.

I think one of the main "trick" here is that end-users might want to use the same LimitRange for Tekton workloads and their own workloads, which might not work for the best.

Yeah that is tricky :/

@vdemeester
Copy link
Member

@vdemeester I'm a bit confused-- this PR isn't intended to cause any changes in behavior; I think I might have just misunderstood what the limitrange transformer does when I wrote these docs. I agree we don't want to be repeatedly changing this behavior.

Oh I see. Well I think it does, here. I don't think the LimitRange controller sets requests or limit to the specified min version in case a default is not present.

@lbernick
Copy link
Member Author

I'm a bit confused-- this PR isn't intended to cause any changes in behavior; I think I might have just misunderstood what the limitrange transformer does when I wrote these docs. I agree we don't want to be repeatedly changing this behavior.

Oh I see. Well I think it does, here. I don't think the LimitRange controller sets requests or limit to the specified min version in case a default is not present.

I think a default will always be present-- k8s always creates the default and sets it to the max as in this example

@vdemeester
Copy link
Member

I think a default will always be present-- k8s always creates the default and sets it to the max as in this example

Ah, interesting 🙃, for some reason I didn't think that was the case 🤔 (maybe on some arcane cluster that maybe didn't have that behavior…). In that case, we might be fine with it 😅

@lbernick
Copy link
Member Author

lbernick commented Sep 6, 2022

@vdemeester would you mind taking another look at this? or are there any unresolved concerns about the behavior re: defaults?

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 6, 2022
@jerop jerop self-assigned this Sep 6, 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.

/lgtm

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jerop, 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 merged commit e2cbc04 into tektoncd:main Sep 7, 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/bug Categorizes issue or PR as related to a bug. 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.

LimitRange transformer behavior inconsistent with our documentation
6 participants