mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-02 11:59:00 +08:00
fix: Dynamic update rate limit config with wrong value (#29901)
when apply dynamic config changes, we should format the value to proper unit This PR fix update rate limit config with wrong value. Signed-off-by: Wei Liu <wei.liu@zilliz.com>
This commit is contained in:
parent
8febbc79bb
commit
fb4fbcf48c
@ -336,7 +336,7 @@ func (rl *rateLimiter) registerLimiters(globalLevel bool) {
|
||||
rl.limiters.GetOrInsert(internalpb.RateType(rt), ratelimitutil.NewLimiter(limit, burst))
|
||||
onEvent := func(rateType internalpb.RateType) func(*config.Event) {
|
||||
return func(event *config.Event) {
|
||||
f, err := strconv.ParseFloat(event.Value, 64)
|
||||
f, err := strconv.ParseFloat(r.Formatter(event.Value), 64)
|
||||
if err != nil {
|
||||
log.Info("Error format for rateLimit",
|
||||
zap.String("rateType", rateType.String()),
|
||||
|
@ -299,12 +299,19 @@ func TestRateLimiter(t *testing.T) {
|
||||
Params.EtcdCfg.EtcdTLSCACert.GetValue(),
|
||||
Params.EtcdCfg.EtcdTLSMinVersion.GetValue())
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
defer cancel()
|
||||
Params.Save(Params.QuotaConfig.DDLLimitEnabled.Key, "true")
|
||||
defer Params.Reset(Params.QuotaConfig.DDLLimitEnabled.Key)
|
||||
Params.Save(Params.QuotaConfig.DMLLimitEnabled.Key, "true")
|
||||
defer Params.Reset(Params.QuotaConfig.DMLLimitEnabled.Key)
|
||||
ctx := context.Background()
|
||||
// avoid production precision issues when comparing 0-terminated numbers
|
||||
newRate := fmt.Sprintf("%.2f1", rand.Float64())
|
||||
etcdCli.KV.Put(ctx, "by-dev/config/quotaAndLimits/dml/insertRate/collection/max", "8")
|
||||
defer etcdCli.KV.Delete(ctx, "by-dev/config/quotaAndLimits/dml/insertRate/collection/max")
|
||||
etcdCli.KV.Put(ctx, "by-dev/config/quotaAndLimits/ddl/collectionRate", newRate)
|
||||
defer etcdCli.KV.Delete(ctx, "by-dev/config/quotaAndLimits/ddl/collectionRate")
|
||||
etcdCli.KV.Put(ctx, "by-dev/config/quotaAndLimits/ddl/partitionRate", "invalid")
|
||||
defer etcdCli.KV.Delete(ctx, "by-dev/config/quotaAndLimits/ddl/partitionRate")
|
||||
|
||||
assert.Eventually(t, func() bool {
|
||||
limit, _ := limiter.limiters.Get(internalpb.RateType_DDLCollection)
|
||||
@ -313,5 +320,8 @@ func TestRateLimiter(t *testing.T) {
|
||||
|
||||
limit, _ := limiter.limiters.Get(internalpb.RateType_DDLPartition)
|
||||
assert.Equal(t, "+inf", limit.Limit().String())
|
||||
|
||||
limit, _ = limiter.limiters.Get(internalpb.RateType_DMLInsert)
|
||||
assert.Equal(t, "8.388608e+06", limit.Limit().String())
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user