You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by me...@apache.org on 2020/12/08 15:17:26 UTC

[apisix] branch master updated: fix: we should use [1, 100] for percentage instead of [0, 100] (#2980)

This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
     new 4719977  fix: we should use [1, 100] for percentage instead of [0, 100] (#2980)
4719977 is described below

commit 471997702b8b3b855e3ceaf93c8aa32571a67981
Author: 罗泽轩 <sp...@gmail.com>
AuthorDate: Tue Dec 8 23:17:18 2020 +0800

    fix: we should use [1, 100] for percentage instead of [0, 100] (#2980)
    
    Previously, we got n+1/101 as the percentage.
---
 apisix/plugins/fault-injection.lua | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/apisix/plugins/fault-injection.lua b/apisix/plugins/fault-injection.lua
index df4ab6a..7a5afb1 100644
--- a/apisix/plugins/fault-injection.lua
+++ b/apisix/plugins/fault-injection.lua
@@ -60,7 +60,7 @@ local function sample_hit(percentage)
         return true
     end
 
-    return random(0, 100) <= percentage
+    return random(1, 100) <= percentage
 end