Skip to content

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

@Toifyx

Description

@Toifyx

文件: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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions