Skip to content

Commit

Permalink
Do not set limits when recommendation is 0
Browse files Browse the repository at this point in the history
  • Loading branch information
Aya Igarashi committed Feb 25, 2021
1 parent 95630b0 commit 237757a
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 237757a

Please sign in to comment.