Skip to content

Commit

Permalink
fix PR
Browse files Browse the repository at this point in the history
  • Loading branch information
kingluo committed Sep 27, 2022
1 parent e998b80 commit a4aeb32
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
15 changes: 12 additions & 3 deletions apisix/admin/consumers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ local core = require("apisix.core")
local plugins = require("apisix.admin.plugins")
local utils = require("apisix.admin.utils")
local plugin = require("apisix.plugin")
local consumer_group = require("apisix.consumer_group")
local pairs = pairs

local _M = {
Expand Down Expand Up @@ -64,8 +63,18 @@ local function check_conf(username, conf)
end

if conf.group_id then
if consumer_group.get(conf.group_id) == nil then
return nil, {error_msg = "invalid consumer group: " .. conf.group_id}
local key = "/consumer_groups/" .. conf.group_id
local res, err = core.etcd.get(key)
if not res then
return nil, {error_msg = "failed to fetch consumer group info by "
.. "consumer group id [" .. conf.group_id .. "]: "
.. err}
end

if res.status ~= 200 then
return nil, {error_msg = "failed to fetch consumer group info by "
.. "consumer group id [" .. conf.group_id .. "], "
.. "response code: " .. res.status}
end
end

Expand Down
2 changes: 1 addition & 1 deletion apisix/core/ctx.lua
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ do
local apisix_var_names = {
balancer_ip = true,
balancer_port = true,
consumer_name = true,
consumer_group_id = true,
consumer_name = true,
route_id = true,
route_name = true,
service_id = true,
Expand Down
2 changes: 1 addition & 1 deletion t/admin/consumer-group.t
Original file line number Diff line number Diff line change
Expand Up @@ -546,4 +546,4 @@ passed
}
}
--- response_body_like
.*invalid consumer group.*
.*failed to fetch consumer group info by consumer group id.*

0 comments on commit a4aeb32

Please sign in to comment.