You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/09/17 09:45:41 UTC

[GitHub] [apisix] tzssangglass opened a new pull request #5083: fix(nacos): distinguish services that has same name but in different groups or namespaces

tzssangglass opened a new pull request #5083:
URL: https://github.com/apache/apisix/pull/5083


   ### What this PR does / why we need it:
   <!--- Why is this change required? What problem does it solve? -->
   <!--- If it fixes an open issue, please link to the issue here. -->
   fix #5061
   ### Pre-submission checklist:
   
   * [x] Did you explain what problem does this PR solve? Or what new features have been added?
   * [x] Have you added corresponding test cases?
   * [ ] Have you modified the corresponding document?
   * [x] Is this PR backward compatible? **If it is not backward compatible, please discuss on the [mailing list](https://github.com/apache/apisix/tree/master#community) first**
   


-- 
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-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] tzssangglass commented on a change in pull request #5083: fix(nacos): distinguish services that has same name but in different groups or namespaces

Posted by GitBox <gi...@apache.org>.
tzssangglass commented on a change in pull request #5083:
URL: https://github.com/apache/apisix/pull/5083#discussion_r713563300



##########
File path: apisix/discovery/nacos.lua
##########
@@ -307,11 +311,21 @@ local function fetch_full_registry(premature)
             return
         end
 
+        if not up_apps[namespace_id] then
+            up_apps[namespace_id] = {}
+        end
+
+        if not up_apps[namespace_id][group_name] then
+            up_apps[namespace_id][group_name] = {}
+        end
+
         for _, host in ipairs(data.hosts) do
-            local nodes = up_apps[service_info.service_name]
+            local nodes = up_apps[namespace_id]
+            [group_name][service_info.service_name]
             if not nodes then
                 nodes = {}
-                up_apps[service_info.service_name] = nodes
+                up_apps[namespace_id]
+                [group_name][service_info.service_name] = nodes

Review comment:
       done

##########
File path: apisix/discovery/nacos.lua
##########
@@ -307,11 +311,21 @@ local function fetch_full_registry(premature)
             return
         end
 
+        if not up_apps[namespace_id] then
+            up_apps[namespace_id] = {}
+        end
+
+        if not up_apps[namespace_id][group_name] then
+            up_apps[namespace_id][group_name] = {}
+        end
+
         for _, host in ipairs(data.hosts) do
-            local nodes = up_apps[service_info.service_name]
+            local nodes = up_apps[namespace_id]
+            [group_name][service_info.service_name]

Review comment:
       done




-- 
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-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] tzssangglass commented on pull request #5083: fix(nacos): distinguish services that has same name but in different groups or namespaces

Posted by GitBox <gi...@apache.org>.
tzssangglass commented on pull request #5083:
URL: https://github.com/apache/apisix/pull/5083#issuecomment-921997041


   base on https://github.com/api7/nacos-test-service/pull/2


-- 
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-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] spacewander merged pull request #5083: fix(nacos): distinguish services that has same name but in different groups or namespaces

Posted by GitBox <gi...@apache.org>.
spacewander merged pull request #5083:
URL: https://github.com/apache/apisix/pull/5083


   


-- 
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-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] tzssangglass commented on a change in pull request #5083: fix(nacos): distinguish services that has same name but in different groups or namespaces

Posted by GitBox <gi...@apache.org>.
tzssangglass commented on a change in pull request #5083:
URL: https://github.com/apache/apisix/pull/5083#discussion_r713556149



##########
File path: apisix/discovery/nacos.lua
##########
@@ -235,12 +237,12 @@ local function iter_and_add_service(services, values)
 
         local namespace_id
         if up.discovery_args then
-            namespace_id = up.discovery_args.namespace_id
+            namespace_id = up.discovery_args.namespace_id or default_namespace_id

Review comment:
       the data of `fetch_full_registry` is from nacos, and the data of `up.discovery_args` is from `conf`, so it's necessary here.




-- 
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-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] spacewander commented on a change in pull request #5083: fix(nacos): distinguish services that has same name but in different groups or namespaces

Posted by GitBox <gi...@apache.org>.
spacewander commented on a change in pull request #5083:
URL: https://github.com/apache/apisix/pull/5083#discussion_r713514538



##########
File path: apisix/discovery/nacos.lua
##########
@@ -307,11 +311,21 @@ local function fetch_full_registry(premature)
             return
         end
 
+        if not up_apps[namespace_id] then
+            up_apps[namespace_id] = {}
+        end
+
+        if not up_apps[namespace_id][group_name] then
+            up_apps[namespace_id][group_name] = {}
+        end
+
         for _, host in ipairs(data.hosts) do
-            local nodes = up_apps[service_info.service_name]
+            local nodes = up_apps[namespace_id]
+            [group_name][service_info.service_name]

Review comment:
       Better to add an indent here

##########
File path: apisix/discovery/nacos.lua
##########
@@ -235,12 +237,12 @@ local function iter_and_add_service(services, values)
 
         local namespace_id
         if up.discovery_args then
-            namespace_id = up.discovery_args.namespace_id
+            namespace_id = up.discovery_args.namespace_id or default_namespace_id

Review comment:
       Look like the default value is not necessary here? We already use one in fetch_full_registry

##########
File path: apisix/discovery/nacos.lua
##########
@@ -307,11 +311,21 @@ local function fetch_full_registry(premature)
             return
         end
 
+        if not up_apps[namespace_id] then
+            up_apps[namespace_id] = {}
+        end
+
+        if not up_apps[namespace_id][group_name] then
+            up_apps[namespace_id][group_name] = {}
+        end
+
         for _, host in ipairs(data.hosts) do
-            local nodes = up_apps[service_info.service_name]
+            local nodes = up_apps[namespace_id]
+            [group_name][service_info.service_name]
             if not nodes then
                 nodes = {}
-                up_apps[service_info.service_name] = nodes
+                up_apps[namespace_id]
+                [group_name][service_info.service_name] = nodes

Review comment:
       Ditto




-- 
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-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] tzssangglass commented on a change in pull request #5083: fix(nacos): distinguish services that has same name but in different groups or namespaces

Posted by GitBox <gi...@apache.org>.
tzssangglass commented on a change in pull request #5083:
URL: https://github.com/apache/apisix/pull/5083#discussion_r711420594



##########
File path: apisix/discovery/nacos.lua
##########
@@ -307,11 +311,21 @@ local function fetch_full_registry(premature)
             return
         end
 
+        if not up_apps[namespace_id] then
+            up_apps[namespace_id] = {}
+        end
+
+        if not up_apps[namespace_id][group_name] then
+            up_apps[namespace_id][group_name] = {}
+        end
+
         for _, host in ipairs(data.hosts) do
-            local nodes = up_apps[service_info.service_name]
+            local nodes = up_apps[namespace_id]
+            [group_name][service_info.service_name]

Review comment:
       done




-- 
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-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] tzssangglass edited a comment on pull request #5083: fix(nacos): distinguish services that has same name but in different groups or namespaces

Posted by GitBox <gi...@apache.org>.
tzssangglass edited a comment on pull request #5083:
URL: https://github.com/apache/apisix/pull/5083#issuecomment-921997041


   ~~base on https://github.com/api7/nacos-test-service/pull/2~~


-- 
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-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] shuaijinchao commented on a change in pull request #5083: fix(nacos): distinguish services that has same name but in different groups or namespaces

Posted by GitBox <gi...@apache.org>.
shuaijinchao commented on a change in pull request #5083:
URL: https://github.com/apache/apisix/pull/5083#discussion_r711192577



##########
File path: apisix/discovery/nacos.lua
##########
@@ -307,11 +311,21 @@ local function fetch_full_registry(premature)
             return
         end
 
+        if not up_apps[namespace_id] then
+            up_apps[namespace_id] = {}
+        end
+
+        if not up_apps[namespace_id][group_name] then
+            up_apps[namespace_id][group_name] = {}
+        end
+
         for _, host in ipairs(data.hosts) do
-            local nodes = up_apps[service_info.service_name]
+            local nodes = up_apps[namespace_id]
+            [group_name][service_info.service_name]

Review comment:
       It will be better to merge it into one line for readability.




-- 
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-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org