You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "kingluo (via GitHub)" <gi...@apache.org> on 2023/03/23 04:40:02 UTC

[GitHub] [apisix] kingluo opened a new pull request, #9150: fix: host_hdr should not be false

kingluo opened a new pull request, #9150:
URL: https://github.com/apache/apisix/pull/9150

   ### Description
   
   <!-- Please include a summary of the change and which issue is fixed. -->
   <!-- Please also include relevant motivation and context. -->
   
   Fixes https://github.com/api7/lua-resty-healthcheck/pull/15#discussion_r1144565155
   
   ### Checklist
   
   - [x] I have explained the need for this PR and the problem it solves
   - [x] I have explained the changes or the new features added to this PR
   - [x] I have added tests corresponding to this change
   - [x] I have updated the documentation to reflect this change
   - [x] I have verified that this change is backward compatible (If not, please discuss on the [APISIX mailing list](https://github.com/apache/apisix/tree/master#community) first)
   
   <!--
   
   Note
   
   1. Mark the PR as draft until it's ready to be reviewed.
   2. Always add/update tests for any changes unless you have a good reason.
   3. Always update the documentation to reflect the changes made in the PR.
   4. Make a new commit to resolve conversations instead of `push -f`.
   5. To resolve merge conflicts, merge master instead of rebasing.
   6. Use "request review" to notify the reviewer after making changes.
   7. Only a reviewer can mark a conversation as resolved.
   
   -->
   


-- 
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] kingluo commented on a diff in pull request #9150: fix: host_hdr should not be false

Posted by "kingluo (via GitHub)" <gi...@apache.org>.
kingluo commented on code in PR #9150:
URL: https://github.com/apache/apisix/pull/9150#discussion_r1147101728


##########
apisix/upstream.lua:
##########
@@ -134,10 +134,13 @@ local function create_checker(upstream)
 
     local host = upstream.checks and upstream.checks.active and upstream.checks.active.host
     local port = upstream.checks and upstream.checks.active and upstream.checks.active.port
-    local up_hdr = upstream.pass_host == "rewrite" and upstream.upstream_host
-    local use_node_hdr = upstream.pass_host == "node"
     for _, node in ipairs(upstream.nodes) do
-        local host_hdr = up_hdr or (use_node_hdr and node.domain)
+        local host_hdr
+        if upstream.pass_host == "rewrite" and upstream.upstream_host then
+            host_hdr = upstream.upstream_host
+        elseif upstream.pass_host == "node" and node.domain then
+            host_hdr = node.domain
+        end

Review Comment:
   @monkeyDluffy6017 Yes, it's the [same](https://www.lua.org/manual/5.1/manual.html#2.5.3), but it's not as clear as explicit conditional statements.



-- 
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] monkeyDluffy6017 commented on a diff in pull request #9150: fix: host_hdr should not be false

Posted by "monkeyDluffy6017 (via GitHub)" <gi...@apache.org>.
monkeyDluffy6017 commented on code in PR #9150:
URL: https://github.com/apache/apisix/pull/9150#discussion_r1147063301


##########
apisix/upstream.lua:
##########
@@ -134,10 +134,13 @@ local function create_checker(upstream)
 
     local host = upstream.checks and upstream.checks.active and upstream.checks.active.host
     local port = upstream.checks and upstream.checks.active and upstream.checks.active.port
-    local up_hdr = upstream.pass_host == "rewrite" and upstream.upstream_host
-    local use_node_hdr = upstream.pass_host == "node"
     for _, node in ipairs(upstream.nodes) do
-        local host_hdr = up_hdr or (use_node_hdr and node.domain)
+        local host_hdr
+        if upstream.pass_host == "rewrite" and upstream.upstream_host then
+            host_hdr = upstream.upstream_host
+        elseif upstream.pass_host == "node" and node.domain then
+            host_hdr = node.domain
+        end

Review Comment:
   The `up_hdr` won't affect the result of `host_hdr`. would this be better?
   ```
       local use_node_hdr = upstream.pass_host == "node" or nil     <== here
       for _, node in ipairs(upstream.nodes) do
           local host_hdr = up_hdr or (use_node_hdr and node.domain)
   ```



-- 
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] monkeyDluffy6017 merged pull request #9150: fix: host_hdr should not be false

Posted by "monkeyDluffy6017 (via GitHub)" <gi...@apache.org>.
monkeyDluffy6017 merged PR #9150:
URL: https://github.com/apache/apisix/pull/9150


-- 
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] monkeyDluffy6017 commented on a diff in pull request #9150: fix: host_hdr should not be false

Posted by "monkeyDluffy6017 (via GitHub)" <gi...@apache.org>.
monkeyDluffy6017 commented on code in PR #9150:
URL: https://github.com/apache/apisix/pull/9150#discussion_r1147063301


##########
apisix/upstream.lua:
##########
@@ -134,10 +134,13 @@ local function create_checker(upstream)
 
     local host = upstream.checks and upstream.checks.active and upstream.checks.active.host
     local port = upstream.checks and upstream.checks.active and upstream.checks.active.port
-    local up_hdr = upstream.pass_host == "rewrite" and upstream.upstream_host
-    local use_node_hdr = upstream.pass_host == "node"
     for _, node in ipairs(upstream.nodes) do
-        local host_hdr = up_hdr or (use_node_hdr and node.domain)
+        local host_hdr
+        if upstream.pass_host == "rewrite" and upstream.upstream_host then
+            host_hdr = upstream.upstream_host
+        elseif upstream.pass_host == "node" and node.domain then
+            host_hdr = node.domain
+        end

Review Comment:
   the result of `host_hdr` is affected by `use_node_hdr`. would this be better?
   ```
       local use_node_hdr = upstream.pass_host == "node" or nil     <== here
       for _, node in ipairs(upstream.nodes) do
           local host_hdr = up_hdr or (use_node_hdr and node.domain)
   ```



-- 
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] monkeyDluffy6017 commented on a diff in pull request #9150: fix: host_hdr should not be false

Posted by "monkeyDluffy6017 (via GitHub)" <gi...@apache.org>.
monkeyDluffy6017 commented on code in PR #9150:
URL: https://github.com/apache/apisix/pull/9150#discussion_r1147154315


##########
apisix/upstream.lua:
##########
@@ -134,10 +134,13 @@ local function create_checker(upstream)
 
     local host = upstream.checks and upstream.checks.active and upstream.checks.active.host
     local port = upstream.checks and upstream.checks.active and upstream.checks.active.port
-    local up_hdr = upstream.pass_host == "rewrite" and upstream.upstream_host
-    local use_node_hdr = upstream.pass_host == "node"
     for _, node in ipairs(upstream.nodes) do
-        local host_hdr = up_hdr or (use_node_hdr and node.domain)
+        local host_hdr
+        if upstream.pass_host == "rewrite" and upstream.upstream_host then
+            host_hdr = upstream.upstream_host
+        elseif upstream.pass_host == "node" and node.domain then
+            host_hdr = node.domain
+        end

Review Comment:
   But we don't need to compare `upstream.pass_host == "rewrite"` and `upstream.pass_host == "node"` every time in loop



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