From db6047bd84b434816269268e0c411df9ea1e3f0f Mon Sep 17 00:00:00 2001 From: lyzs90 Date: Fri, 5 Feb 2021 22:03:22 +0800 Subject: [PATCH] Guard against non positive time limit --- clusterloader2/pkg/tuningset/randomized_time_limited.go | 5 ++++- clusterloader2/testing/load/config.yaml | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/clusterloader2/pkg/tuningset/randomized_time_limited.go b/clusterloader2/pkg/tuningset/randomized_time_limited.go index 64a061e727..9d103cc5f9 100644 --- a/clusterloader2/pkg/tuningset/randomized_time_limited.go +++ b/clusterloader2/pkg/tuningset/randomized_time_limited.go @@ -40,7 +40,10 @@ func (r *randomizedTimeLimitedLoad) Execute(actions []func()) { index := i wg.Start(func() { // Sleeps for random duration in [0, TimeLimit]. - time.Sleep(time.Duration(rand.Int63n(r.params.TimeLimit.ToTimeDuration().Nanoseconds()))) + timeLimit := r.params.TimeLimit.ToTimeDuration().Nanoseconds() + if timeLimit > 0 { + time.Sleep(time.Duration(rand.Int63n(timeLimit))) + } actions[index]() }) } diff --git a/clusterloader2/testing/load/config.yaml b/clusterloader2/testing/load/config.yaml index 8cfed51b92..62513a3fd0 100644 --- a/clusterloader2/testing/load/config.yaml +++ b/clusterloader2/testing/load/config.yaml @@ -126,7 +126,7 @@ tuningSets: # The expected number of created/deleted pods is totalPods/4 when scaling, # as each RS changes its size from X to a uniform random value in [X/2, 3X/2]. # To match 10 [pods/s] requirement, we need to divide saturationTime by 4. - timeLimit: {{MaxInt 1 (DivideInt $saturationTime 4)}}s + timeLimit: {{DivideInt $saturationTime 4}}s - name: RandomizedDeletionTimeLimited RandomizedTimeLimitedLoad: timeLimit: {{$deletionTime}}s