nic-6443 commented on code in PR #12413: URL: https://github.com/apache/apisix/pull/12413#discussion_r2194341422
########## apisix/consumer.lua: ########## @@ -159,17 +120,49 @@ function plugin_consumer() conf_version = consumers.conf_version } end - - local consumer = consumers_id_lrucache(val.value.id .. name, - val.modifiedIndex, construct_consumer_data, val, config) - if consumer == nil then - goto CONTINUE + -- if the val is a Consumer, clone it to the local consumer; + -- if the val is a Credential, to get the Consumer by consumer_name and then clone + -- it to the local consumer. + local consumer + if is_credential_etcd_key(val.key) then + local consumer_name = get_consumer_name_from_credential_etcd_key(val.key) + local the_consumer = consumers:get(consumer_name) + if the_consumer and the_consumer.value then + consumer = consumers_id_lrucache(the_consumer.value, val.modifiedIndex+the_consumer.modifiedIndex, + function (val, the_consumer) + consumer = core.table.clone(the_consumer.value) + consumer.modifiedIndex = the_consumer.modifiedIndex + consumer.credential_id = get_credential_id_from_etcd_key(val.key) + return consumer + end, val, the_consumer) + else + -- Normally wouldn't get here: + -- it should belong to a consumer for any credential. + core.log.error("failed to get the consumer for the credential,", + " a wild credential has appeared!", + " credential key: ", val.key, ", consumer name: ", consumer_name) + goto CONTINUE + end + else + consumer = consumers_id_lrucache(val.value, val.modifiedIndex, Review Comment: ```suggestion consumer = consumers_id_lrucache(val.key, val.modifiedIndex, ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@apisix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org