-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
LimitRange calculation should only split Requests for Step Containers #4996
Conversation
/cc @lbernick |
/retest |
The following is the coverage report on the affected files.
|
This commit changes how resource requirements are calculated when one or more LimitRanges are present in the namespace where a TaskRun is. We now will only transform "step" containers and exclude all other app containers (e.g. sidecars and any other containers) when splitting "requests" from LimitRanges. Existing tests have been fixed to use "Step" containers and two additional tests have been added to verify behavior when a sidecar is present. Docs have been updated to reflect this change
828ecdd
to
bbc549b
Compare
The following is the coverage report on the affected files.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks Simon!
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: lbernick 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 |
/test pull-tekton-pipeline-alpha-integration-tests |
/test pull-tekton-pipeline-integration-tests |
- the LimitRange minimum resource requests | ||
- the LimitRange default resource requests, divided among the app containers | ||
- the LimitRange default resource requests (for init and Sidecar containers) or the LimitRange default resource requests divided by the number of Step containers (for Step containers) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you for clarifying this 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lee's new and improved wording not mine ;)
nbContainers := len(p.Spec.Containers) | ||
nbStepContainers := 0 | ||
for _, c := range p.Spec.Containers { | ||
if pod.IsContainerStep(c.Name) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to check for the running containers or any other specific state (not-running) of the container here? or the state of container does not matter at this point since they will be spawned with the configuration being determined here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alright, so this is only used in pod builder while creating a pod so the state is not relevant here ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The transform happens before the pod spec is applied so the state of the container does not matter at this point. We use the number of step containers to help choose the optimal request size at configuration generation time.
defaultRequests := getDefaultAppContainerRequest(limitRange, nbContainers) | ||
for i := range p.Spec.Containers { | ||
for i, c := range p.Spec.Containers { | ||
var defaultRequests = defaultContainerRequests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hardly see this way of initializing and declaring a variable, interesting 🙃
} | ||
} | ||
} | ||
} | ||
// return nil if the resource list is empty to avoid setting an empty defaultrequest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: should this be done for the other two other get
functions - getDefaultContainerRequest
and getDefaultLimits
? I havent looked at whether its needed or not but just wondering since we added this here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Glad you noticed ;) They actually already will return nil. The getStepContainerRequest creates an empty request list before trying to populate so this empty check to return nil makes it consistent with the others.
thank you @skaegi, I have one /lgtm |
Changes
This commit changes how resource requirements are calculated when one or more LimitRanges are present in the namespace where a TaskRun is.
We now will only transform "step" containers and exclude all other app containers (e.g. sidecars and any other containers) when splitting "requests" from LimitRanges.
Existing tests have been fixed to use "Step" containers and two additional tests have been added to verify behavior when a sidecar is present.
Docs have been updated to reflect this change
Cleanup:
resources
requirements for a container as this is not needed and adds clutter.Fixes #4978
/kind bug
Submitter Checklist
As the author of this PR, please check off the items in this checklist:
functionality, content, code)
(if there are no user facing changes, use release note "NONE")
Release Notes