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

Ac take care of limit range #1813

Closed

Conversation

safanaj
Copy link
Contributor

@safanaj safanaj commented Mar 22, 2019

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Mar 22, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To fully approve this pull request, please assign additional approvers.
We suggest the following additional approver: bskiba

If they are not already assigned, you can assign the PR to them by writing /assign @bskiba in a comment when ready.

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

@k8s-ci-robot k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Mar 22, 2019
@k8s-ci-robot k8s-ci-robot requested review from bskiba and mwielgus March 22, 2019 09:31
@safanaj safanaj force-pushed the ac-take-care-of-limit-range branch from 2403a97 to 98d2a05 Compare March 25, 2019 08:38
@bskiba
Copy link
Member

bskiba commented Mar 29, 2019

Thank you for this PR. There is good work here. We will review early next week, still discussing some points.
@kgolab

@@ -0,0 +1,251 @@
/*
Copyright 2018 The Kubernetes Authors.
Copy link
Member

Choose a reason for hiding this comment

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

2019

}

type interestingData struct {
// Min v1.ResourceList
Copy link
Member

Choose a reason for hiding this comment

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

Should this be part of this PR?


var _ LimitsChecker = &limitsChecker{}

// NewLimitsChecker create a LimitsChecker
Copy link
Member

Choose a reason for hiding this comment

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

nit: creates

var _ LimitsChecker = &neverNeedsLimitsChecker{}

func (lc *neverNeedsLimitsChecker) NeedsLimits(pod *v1.Pod, containersResources []ContainerResources) LimitsHints {
return LimitsHints((*LimitRangeHints)(nil))
Copy link
Member

Choose a reason for hiding this comment

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

It might be simpler if we returned an object with two empty lists instead of nil.

@@ -121,7 +121,7 @@ func (vpa *Vpa) UseAggregationIfMatching(aggregationKey AggregateStateKey, aggre
}
}

// UsesAggregation returns true iff an aggregation with the given key contributes to the VPA.
// UsesAggregation returns true if an aggregation with the given key contributes to the VPA.
Copy link
Member

Choose a reason for hiding this comment

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

This is not a typo - iff means if and only if

var _ LimitsChecker = &limitsChecker{}

// NewLimitsChecker create a LimitsChecker
func NewLimitsChecker(i interface{}) LimitsChecker {
Copy link
Member

Choose a reason for hiding this comment

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

Can we have a SharedInformerFactory passed here?

@@ -75,11 +78,14 @@ func main() {
vpaLister := vpa_api_util.NewAllVpasLister(vpaClient, make(chan struct{}))
kubeClient := kube_client.NewForConfigOrDie(config)
factory := informers.NewSharedInformerFactory(kubeClient, defaultResyncPeriod)
if *allowToAdjustLimits {
factoryForLimitsChecker = factory
Copy link
Member

Choose a reason for hiding this comment

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

I'd rather explicitly pass the no-op limitChecker when *allowToAdjustLimits = false


// Set limit if needed
if limitsHints.RequestsExceedsRatio(i, resource) {
// we need just to take care of max ratio
Copy link
Member

Choose a reason for hiding this comment

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

Why?


// LimitRangeHints implements LimitsHints interface
type LimitRangeHints struct {
requestsExceedsRatio []map[v1.ResourceName]bool
Copy link
Member

Choose a reason for hiding this comment

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

since v1.ResourceList is already a map, can we store proposedLimits map[container_name]proposed_limit_changes
Then:

requestExceedsRatio(container_name, resourceName) bool {
_, found := proposedLimits[container_name][resourceName]
return found
}

limitranges, err := lc.limitrangeLister.
LimitRanges(pod.GetNamespace()).
List(labels.Everything())
if err == nil {
Copy link
Member

Choose a reason for hiding this comment

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

I'd rather fail fast:
if err != nil {
return nil
}

Copy link
Member

Choose a reason for hiding this comment

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

Also, it would be good to log the error.

continue
}
foundInterstingData = true
id.parse(&lri)
Copy link
Member

@bskiba bskiba Apr 3, 2019

Choose a reason for hiding this comment

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

Is it possible to have multiple items that have non nil MaxLimitRequestRatio per namespace?

@@ -0,0 +1,236 @@
/*
Copyright 2018 The Kubernetes Authors.
Copy link
Member

Choose a reason for hiding this comment

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

nit: 2019

@bskiba
Copy link
Member

bskiba commented Apr 3, 2019

Thank you very much for this PR, it is needed functionality for VPA.

I left some initial comments. My main concern is why do we only care about MaxRatio? I assume we can also easily violate the MinRatio constraint.

@safanaj
Copy link
Contributor Author

safanaj commented Apr 8, 2019

Thanks for the comments, I will take these as soon as I have time

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 27, 2019
@safanaj safanaj force-pushed the ac-take-care-of-limit-range branch from 98d2a05 to 5304a4b Compare April 29, 2019 08:11
@k8s-ci-robot k8s-ci-robot added do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Apr 29, 2019
@safanaj safanaj changed the base branch from master to vpa-release-0.5 April 29, 2019 08:33
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Apr 29, 2019
@safanaj safanaj changed the base branch from vpa-release-0.5 to master April 29, 2019 08:33
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Apr 29, 2019
@safanaj safanaj force-pushed the ac-take-care-of-limit-range branch from 49725d3 to cb63756 Compare May 10, 2019 13:00
@k8s-ci-robot k8s-ci-robot removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. labels May 10, 2019
To allow admission controller to set limits on containers if needed
because LimitRange in namespace with default and max ratio.
This feature have to be explicitly enabled by passing the flag `--allow-to-adjust-limits`
@safanaj safanaj force-pushed the ac-take-care-of-limit-range branch from cb63756 to 8b813d5 Compare May 10, 2019 13:09
@safanaj
Copy link
Contributor Author

safanaj commented May 10, 2019

Hi @bskiba I am sorry for the delay but was a very busy month for me.
I re-pushed the branch for the PR rebased on master. I addressed several of you comments. For other I am not sure.

My main concern is why do we only care about MaxRatio? I assume we can also easily violate the MinRatio constraint.

The min ratio is 1:1 and this would make limits equals to requests would make a pod in Guaranteed (QoS). In LimitRange API there is no MinRatio property.

Is it possible to have multiple items that have non nil MaxLimitRequestRatio per namespace?

Yes it is possible and in this case all ratio have to be respected so I get the minimum one. For the Default, to consider the limit quantity in case on the container there is not an explicit limit, is not so clear (and I am not sure if my code is correct) because looks like that the LimitRanger set the default limit from the first LimitRange it gets the problem here is that the query using the client-go could return a different order compared to what LimitRanger get on the server-side . I didn't verify this, btw I think that is quite uncommon to have multiple LimitRange for the same resources in a namespace.

@bskiba
Copy link
Member

bskiba commented May 14, 2019

Thanks for the changes and the explanation. It was my oversight that I din't check properly that there is no corresponding minLimit, apologies.
I need some more time to review.

jbartosik added a commit to jbartosik/autoscaler that referenced this pull request May 20, 2019
I'm keeping original CL from kubernetes#1813
and applying changes requested in the review in a separate CL to keep
autoship information clean.
@bskiba
Copy link
Member

bskiba commented May 30, 2019

@safanaj I believe the other PRs (based on this one) fix the original issue. I'm closing this, let me know if there is something still to be adressed.
/close

@k8s-ci-robot
Copy link
Contributor

@bskiba: Closed this PR.

In response to this:

@safanaj I believe the other PRs (based on this one) fix the original issue. I'm closing this, let me know if there is something still to be adressed.
/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

jbartosik added a commit to jbartosik/autoscaler that referenced this pull request Jun 7, 2019
I'm keeping original CL from kubernetes#1813
and applying changes requested in the review in a separate CL to keep
autoship information clean.

Conflicts because master has VPA preprocessor, resolved manually:
	vertical-pod-autoscaler/pkg/admission-controller/logic/server_test.go
	vertical-pod-autoscaler/pkg/admission-controller/main.go
jbartosik added a commit to jbartosik/autoscaler that referenced this pull request Jun 11, 2019
I'm keeping original CL from kubernetes#1813
and applying changes requested in the review in a separate CL to keep
autoship information clean.

Conflicts because master has VPA preprocessor, resolved manually:
	vertical-pod-autoscaler/pkg/admission-controller/logic/server_test.go
	vertical-pod-autoscaler/pkg/admission-controller/main.go
tim-smart pushed a commit to arisechurch/autoscaler that referenced this pull request Nov 22, 2022
I'm keeping original CL from kubernetes#1813
and applying changes requested in the review in a separate CL to keep
autoship information clean.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/vertical-pod-autoscaler cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. 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.

3 participants