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/06/02 12:24:32 UTC

[GitHub] [apisix] yxudong opened a new pull request #4361: add etcd retry when init

yxudong opened a new pull request #4361:
URL: https://github.com/apache/apisix/pull/4361


   ### What this PR does / why we need it:
   
   https://github.com/apache/apisix/issues/3953
   
   ### Pre-submission checklist:
   
   * [x] Did you explain what problem does this PR solve? Or what new features have been added?
   * [ ] 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.

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



[GitHub] [apisix] yxudong commented on a change in pull request #4361: feat: add etcd retry when init

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



##########
File path: apisix/cli/etcd.lua
##########
@@ -191,10 +191,21 @@ function _M.init(env, args)
         local version_url = host .. "/version"
         local errmsg
 
-        local res, err = request(version_url, yaml_conf)
-        -- In case of failure, request returns nil followed by an error message.
-        -- Else the first return value is the response body
-        -- and followed by the response status code.
+        local res, err
+        local retry_time = 0
+        while retry_time < 2 do
+            res, err = request(version_url, yaml_conf)
+            -- In case of failure, request returns nil followed by an error message.
+            -- Else the first return value is the response body
+            -- and followed by the response status code.
+            if res then
+                break
+            end
+            retry_time = retry_time + 1
+            print(str_format("Warning! Request etcd endpoint \'%s\' error, %s, retry_time=%s",
+                             version_url, err, retry_time))

Review comment:
       > Ping @yxudong
   
   Get it, I‘ll do it soon.




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

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



[GitHub] [apisix] spacewander commented on a change in pull request #4361: feat: add etcd retry when init

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



##########
File path: apisix/cli/etcd.lua
##########
@@ -191,10 +191,21 @@ function _M.init(env, args)
         local version_url = host .. "/version"
         local errmsg
 
-        local res, err = request(version_url, yaml_conf)
-        -- In case of failure, request returns nil followed by an error message.
-        -- Else the first return value is the response body
-        -- and followed by the response status code.
+        local res, err
+        local retry_time = 0
+        while retry_time < 2 do
+            res, err = request(version_url, yaml_conf)
+            -- In case of failure, request returns nil followed by an error message.
+            -- Else the first return value is the response body
+            -- and followed by the response status code.
+            if res then
+                break
+            end
+            retry_time = retry_time + 1
+            print(str_format("Warning! Request etcd endpoint \'%s\' error, %s, retry_time=%s",
+                             version_url, err, retry_time))

Review comment:
       Need a test in https://github.com/apache/apisix/blob/master/t/cli/test_etcd.sh




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

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



[GitHub] [apisix] spacewander merged pull request #4361: feat: add etcd retry when init

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


   


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

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



[GitHub] [apisix] spacewander commented on a change in pull request #4361: feat: add etcd retry when init

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



##########
File path: apisix/cli/etcd.lua
##########
@@ -191,10 +191,21 @@ function _M.init(env, args)
         local version_url = host .. "/version"
         local errmsg
 
-        local res, err = request(version_url, yaml_conf)
-        -- In case of failure, request returns nil followed by an error message.
-        -- Else the first return value is the response body
-        -- and followed by the response status code.
+        local res, err
+        local retry_time = 0
+        while retry_time < 2 do
+            res, err = request(version_url, yaml_conf)
+            -- In case of failure, request returns nil followed by an error message.
+            -- Else the first return value is the response body
+            -- and followed by the response status code.
+            if res then
+                break
+            end
+            retry_time = retry_time + 1
+            print(str_format("Warning! Request etcd endpoint \'%s\' error, %s, retry_time=%s",
+                             version_url, err, retry_time))

Review comment:
       Ping @yxudong 




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

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



[GitHub] [apisix] spacewander commented on a change in pull request #4361: feat: add etcd retry when init

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



##########
File path: t/cli/test_etcd.sh
##########
@@ -80,6 +80,24 @@ fi
 
 echo "passed: properly handle the error when connecting to etcd without auth"
 
+# Check etcd retry if connect failed
+git checkout conf/config.yaml
+
+echo '
+etcd:
+  host:

Review comment:
       Better to expand the tab to space




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

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



[GitHub] [apisix] yxudong commented on a change in pull request #4361: feat: add etcd retry when init

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



##########
File path: t/cli/test_etcd.sh
##########
@@ -80,6 +80,24 @@ fi
 
 echo "passed: properly handle the error when connecting to etcd without auth"
 
+# Check etcd retry if connect failed
+git checkout conf/config.yaml
+
+echo '
+etcd:
+  host:

Review comment:
       > Better to expand the tab to space
   
   Sorry, I‘m not understand.
   I just copy other code in same file and do some modify. 
   The code style is same. And it's seems no tab in this file.




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

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