Skip to content

Commit

Permalink
Merge pull request #3903 from Ladicle/vpa-fix-limit-patch
Browse files Browse the repository at this point in the history
Do not set limits when recommendation is 0
  • Loading branch information
k8s-ci-robot authored Mar 16, 2021
2 parents 5d05268 + 237757a commit b2951aa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ func getProportionalResourceLimit(resourceName core.ResourceName, originalLimit,
if originalLimit == nil || originalLimit.Value() == 0 {
return nil, ""
}
// recommendedRequest not set, don't set limit.
if recommendedRequest == nil || recommendedRequest.Value() == 0 {
return nil, ""
}
// originalLimit set but originalRequest not set - K8s will treat the pod as if they were equal,
// recommend limit equal to request
if originalRequest == nil || originalRequest.Value() == 0 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ func TestGetProportionalResourceLimit(t *testing.T) {
recommendedRequest: mustParseToPointer("10"),
expectLimit: mustParseToPointer("10"),
},
{
name: "no recommendation",
originalRequest: mustParseToPointer("1"),
recommendedRequest: mustParseToPointer("0"),
defaultLimit: mustParseToPointer("2"),
expectLimit: nil,
},
{
name: "limit equal to request",
originalLimit: mustParseToPointer("1"),
Expand Down

0 comments on commit b2951aa

Please sign in to comment.