Copilot commented on code in PR #13991:
URL: https://github.com/apache/apisix/pull/13991#discussion_r4131657017
##########
apisix/discovery/kubernetes/init.lua:
##########
@@ -154,7 +161,86 @@ local function multiple_mode_init(confs)
end
-local function multiple_mode_nodes(service_name)
+local function merge_cluster_nodes(endpoint_dicts, endpoint_key, endpoint_port)
+ local nodes = {}
+ local seen = {}
+ for _, endpoint_dict in ipairs(endpoint_dicts) do
+ local cluster_nodes = k8s_core.create_endpoint_lrucache(endpoint_dict,
endpoint_key,
+ endpoint_port)
+ for _, node in ipairs(cluster_nodes or {}) do
+ local addr = node.host .. ":" .. tostring(node.port)
+ if not seen[addr] then
+ seen[addr] = true
+ core.table.insert(nodes, node)
+ end
+ end
+ end
+
+ return nodes
+end
+
+
+-- with cluster_ids, service_name is "namespace/name:port_name"
+local cluster_ids_service_name_pattern = [[^([^/]+/[^/:]+):(.+)$]]
Review Comment:
This pattern still accepts malformed values such as `ns:extra/svc:p1` and
`ns/svc:p1:extra`, so the Admin API accepts them even though they do not match
the documented `namespace/name:port_name` shape; they then fail later as
missing endpoints. Exclude both delimiters from every component so these
configurations are rejected during validation.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]