add canary-weight-total annotation (#6338)

This commit is contained in:
Yecheng Fu 2021-12-08 00:40:00 +08:00 committed by GitHub
parent 6163231ef6
commit 5cff197bc5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 71 additions and 5 deletions

View file

@ -259,7 +259,11 @@ local function route_to_alternative_balancer(balancer)
end
end
if math.random(100) <= traffic_shaping_policy.weight then
local weightTotal = 100
if traffic_shaping_policy.weightTotal ~= nil and traffic_shaping_policy.weightTotal > 100 then
weightTotal = traffic_shaping_policy.weightTotal
end
if math.random(weightTotal) <= traffic_shaping_policy.weight then
return true
end