From 0bee739a2f2b75cfaa6fa7c7b5b3a63dc41d95d1 Mon Sep 17 00:00:00 2001 From: shawnhanx Date: Tue, 15 Dec 2020 23:26:41 +0800 Subject: [PATCH 1/2] Change the upper limit of threshold from 10000% to 100% --- pkg/kubelet/eviction/helpers.go | 3 ++- pkg/kubelet/eviction/helpers_test.go | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/pkg/kubelet/eviction/helpers.go b/pkg/kubelet/eviction/helpers.go index 322f618bf1b..5d97dad782e 100644 --- a/pkg/kubelet/eviction/helpers.go +++ b/pkg/kubelet/eviction/helpers.go @@ -203,7 +203,8 @@ func parseThresholdStatement(signal evictionapi.Signal, val string) (*evictionap if percentage < 0 { return nil, fmt.Errorf("eviction percentage threshold %v must be >= 0%%: %s", signal, val) } - if percentage > 100 { + // percentage is a float and should not be greater than 1(100%) + if percentage > 1 { return nil, fmt.Errorf("eviction percentage threshold %v must be <= 100%%: %s", signal, val) } return &evictionapi.Threshold{ diff --git a/pkg/kubelet/eviction/helpers_test.go b/pkg/kubelet/eviction/helpers_test.go index 5b4e729fe6c..c6a76b0d2e1 100644 --- a/pkg/kubelet/eviction/helpers_test.go +++ b/pkg/kubelet/eviction/helpers_test.go @@ -387,6 +387,15 @@ func TestParseThresholdConfig(t *testing.T) { expectErr: true, expectThresholds: []evictionapi.Threshold{}, }, + "hard-signal-percentage-greater-than-100%": { + allocatableConfig: []string{}, + evictionHard: map[string]string{"memory.available": "150%"}, + evictionSoft: map[string]string{}, + evictionSoftGracePeriod: map[string]string{}, + evictionMinReclaim: map[string]string{}, + expectErr: true, + expectThresholds: []evictionapi.Threshold{}, + }, "soft-signal-negative": { allocatableConfig: []string{}, evictionHard: map[string]string{}, From fa8d07d3e1aa534601a90e527ed8d5321796fc6c Mon Sep 17 00:00:00 2001 From: shawnhanx <59723284+shawnhanx@users.noreply.github.com> Date: Sun, 7 Feb 2021 09:23:07 +0800 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: bl-ue <54780737+bl-ue@users.noreply.github.com> --- pkg/kubelet/eviction/helpers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/kubelet/eviction/helpers.go b/pkg/kubelet/eviction/helpers.go index 5d97dad782e..3585b6565e9 100644 --- a/pkg/kubelet/eviction/helpers.go +++ b/pkg/kubelet/eviction/helpers.go @@ -203,7 +203,7 @@ func parseThresholdStatement(signal evictionapi.Signal, val string) (*evictionap if percentage < 0 { return nil, fmt.Errorf("eviction percentage threshold %v must be >= 0%%: %s", signal, val) } - // percentage is a float and should not be greater than 1(100%) + // percentage is a float and should not be greater than 1 (100%) if percentage > 1 { return nil, fmt.Errorf("eviction percentage threshold %v must be <= 100%%: %s", signal, val) }