diff --git a/apisix/admin/consumers.lua b/apisix/admin/consumers.lua index b0e461eb329d..7ab0ec1e2ad2 100644 --- a/apisix/admin/consumers.lua +++ b/apisix/admin/consumers.lua @@ -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 = { @@ -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 diff --git a/apisix/core/ctx.lua b/apisix/core/ctx.lua index 715d2dce9fde..9b589b6b38e4 100644 --- a/apisix/core/ctx.lua +++ b/apisix/core/ctx.lua @@ -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, diff --git a/t/admin/consumer-group.t b/t/admin/consumer-group.t index bc10a409770b..176ed9f8aab8 100644 --- a/t/admin/consumer-group.t +++ b/t/admin/consumer-group.t @@ -546,4 +546,4 @@ passed } } --- response_body_like -.*invalid consumer group.* +.*failed to fetch consumer group info by consumer group id.*