Yiyiyimu commented on a change in pull request #4191:
URL: https://github.com/apache/apisix/pull/4191#discussion_r658647753



##########
File path: apisix/core/config_etcd.lua
##########
@@ -545,7 +558,34 @@ local function _automatic_fetch(premature, self)
 
             local ok, err = sync_data(self)
             if err then
-                if err ~= "timeout" and err ~= "Key not found"
+                if string.find(err, "connection refused")
+                    or string.find(err, "Service Unavailable") then
+                    log.warn(err, ", ", tostring(self))

Review comment:
       This part got removed

##########
File path: apisix/core/config_etcd.lua
##########
@@ -545,7 +558,34 @@ local function _automatic_fetch(premature, self)
 
             local ok, err = sync_data(self)
             if err then
-                if err ~= "timeout" and err ~= "Key not found"
+                if string.find(err, "connection refused")
+                    or string.find(err, "Service Unavailable") then
+                    log.warn(err, ", ", tostring(self))
+                    local etcd_cli, err = get_etcd(true)
+                    if not etcd_cli then
+                        error("all etcd endpoints are unhealthy: " .. err)
+                    end
+                    self.etcd_cli = etcd_cli
+                    log.warn("changed to new etcd endpoint")
+                elseif string.find(err, "has no healthy etcd endpoint 
available") then
+                    log.warn(err, ", ", tostring(self))
+                    local reconnected = false
+                    while err and not reconnected do
+                        local backoff_duration, backoff_factor, backoff_step = 
1, 2, 10
+                        for _ = 0, backoff_step, 1 do
+                            ngx_sleep(backoff_duration)
+                            _, err = sync_data(self)
+                            if not string.find(err, "has no healthy etcd 
endpoint available") then

Review comment:
       Fixed. Thanks!




-- 
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:
[email protected]


Reply via email to