tzssangglass commented on code in PR #8219:
URL: https://github.com/apache/apisix/pull/8219#discussion_r1021021577


##########
apisix/admin/stream_routes.lua:
##########
@@ -16,15 +16,42 @@
 --
 local core = require("apisix.core")
 local utils = require("apisix.admin.utils")
+local config_util = require("apisix.core.config_util")

Review Comment:
   ```suggestion
   local iterate_values = require("apisix.core.config_util").iterate_values
   ```



##########
apisix/admin/stream_routes.lua:
##########
@@ -16,15 +16,42 @@
 --
 local core = require("apisix.core")
 local utils = require("apisix.admin.utils")
+local config_util = require("apisix.core.config_util")
 local stream_route_checker = 
require("apisix.stream.router.ip_port").stream_route_checker
 local tostring = tostring
+local ngx = ngx
+local table = table
+local tonumber = tonumber
 
 
 local _M = {
     version = 0.1,
     need_v3_filter = true,
 }
 
+local function check_router_refer(items, id)
+    local warn_message = nil
+    local refer_list =  core.tablepool.fetch("refer_list",#items,0)
+    for _, item in config_util.iterate_values(items) do
+        if item.value == nil then
+            goto CONTINUE
+        end
+        local r_id = ngx.re.gsub(item["key"], "/", "_")
+        local route = item.value
+        if route.protocol and route.protocol.superior_id and 
route.protocol.superior_id == id then
+            table.insert(refer_list,r_id)
+        end

Review Comment:
   ```suggestion
           local route = item.value
           if route.protocol and route.protocol.superior_id and 
route.protocol.superior_id == id then
               table.insert(refer_list, item["key"])
           end
   ```



##########
apisix/stream/router/ip_port.lua:
##########
@@ -63,23 +63,46 @@ local create_router
 do
     local sni_to_items = {}
     local tls_routes = {}
+    local routeid_to_protocols = {}
 
     function create_router(items)
         local tls_routes_idx = 1
         local other_routes_idx = 1
         core.table.clear(tls_routes)
         core.table.clear(other_routes)
         core.table.clear(sni_to_items)
+        core.table.clear(routeid_to_protocols)
 
         for _, item in config_util.iterate_values(items) do
             if item.value == nil then
                 goto CONTINUE
             end
+            local route = item.value
+            if route.protocol  then
+               routeid_to_protocols[item.key]=route.protocol.name
+            else
+               routeid_to_protocols[item.key]="No-Protocol"
+            end
+            ::CONTINUE::
+        end
 
+        for _, item in config_util.iterate_values(items) do
+            if item.value == nil then
+                goto CONTINUE
+            end
             local route = item.value
             if route.protocol and route.protocol.superior_id then
                 -- subordinate route won't be matched in the entry
-                -- TODO: check the subordinate relationship in the Admin API
+                local key="/apisix/stream_routes/"..route.protocol.superior_id
+                if routeid_to_protocols[key] == nil then
+                    core.log.warn("There is not exist stream_route: "..key)
+                elseif routeid_to_protocols[key] == "No-Protocol" then
+                    core.log.warn("The stream_route: "..key.." may lacks 
procotol configuration")
+                elseif routeid_to_protocols[key] == route.protocol.name then
+                    goto CONTINUE
+                else
+                    core.log.warn("Different between 
stream_route:"..item.key.." and "..key)
+                end
                 goto CONTINUE

Review Comment:
   It seems we don't need to modify here? I see that the test cases don't cover 
the changes here.



##########
apisix/admin/stream_routes.lua:
##########
@@ -16,15 +16,42 @@
 --
 local core = require("apisix.core")
 local utils = require("apisix.admin.utils")
+local config_util = require("apisix.core.config_util")
 local stream_route_checker = 
require("apisix.stream.router.ip_port").stream_route_checker
 local tostring = tostring
+local ngx = ngx
+local table = table
+local tonumber = tonumber
 
 
 local _M = {
     version = 0.1,
     need_v3_filter = true,
 }
 
+local function check_router_refer(items, id)
+    local warn_message = nil
+    local refer_list =  core.tablepool.fetch("refer_list",#items,0)
+    for _, item in config_util.iterate_values(items) do

Review Comment:
   ```suggestion
       for _, item in iterate_values(items) do
   ```



-- 
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]

Reply via email to