Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtimeset 操作时,会删除原策略,再设置新策略,如果后续报错policy NO 不存在,会导致原策略设置的规则被删。建议删除放在判断之后。 #100

Open
Toifyx opened this issue Oct 17, 2018 · 0 comments

Comments

@Toifyx
Copy link

Toifyx commented Oct 17, 2018

文件:admin/runtime.lua 186行

local pfunc = function()
local runtimeGroupMod = runtimeGroupModule:new(database, runtimeLib)
return runtimeGroupMod:del(hostname)
end
local status, info = xpcall(pfunc, handler)
if not status then
local response = doerror(info)
ngx.say(response)
return false
end

local pfunc = function()
    local policyMod = policyModule:new(database, policyLib)
    local policy = policyMod:get(policyId)

    local divtype = policy.divtype
    local divdata = policy.divdata

    if divtype == ngx.null or divdata == ngx.null then
        error{ERRORINFO.POLICY_BLANK_ERROR, 'policy NO '..policyId}
    end

    if not divtypes[divtype] then

    end

    local prefix             = hostname .. ':first'
    local divModulename      = table.concat({'abtesting', 'diversion', divtype}, '.')
    local divDataKey         = table.concat({policyLib, policyId, fields.divdata}, ':')
    local userInfoModulename = table.concat({'abtesting', 'userinfo', divtypes[divtype]}, '.')
    local runtimeMod         = runtimeModule:new(database, runtimeLib) 
    runtimeMod:set(prefix, divModulename, divDataKey, userInfoModulename)

    local divSteps           = runtimeLib .. ':' .. hostname .. ':' .. fields.divsteps
    local ok, err = database:set(divSteps, 1)
    if not ok then error{ERRORINFO.REDIS_ERROR, err} end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant