zaunist commented on a change in pull request #6202:
URL: https://github.com/apache/apisix/pull/6202#discussion_r812537327



##########
File path: apisix/plugins/server-info.lua
##########
@@ -132,51 +124,111 @@ local function get_server_info()
 end
 
 
+local function set(key, value, ttl)
+    local res_new, err = core.etcd.set(key, value, ttl)
+    if not res_new then
+        core.log.error("failed to set server_info: ", err)
+        return 503, {error_msg = err}
+    end
+
+    if not res_new.body.lease_id then
+        core.log.error("failed to get lease_id: ", err)
+        return 503, {error_msg = err}
+    end
+
+    lease_id = res_new.body.lease_id
+
+    -- set or update lease_id
+    local ok, err = internal_status:set("lease_id", lease_id)
+    if not ok then
+        core.log.error("failed to set lease_id to shdict: ", err)
+        return 503, {error_msg = err}
+    end
+
+    return 200, nil
+end
+
+
 local function report(premature, report_ttl)
     if premature then
         return
     end
 
+    -- get apisix node info
     local server_info, err = get()
     if not server_info then
         core.log.error("failed to get server_info: ", err)
-        return
+        return 500, {error_msg = err}
     end
 
     if server_info.etcd_version == "unknown" then
         local res, err = core.etcd.server_version()
         if not res then
             core.log.error("failed to fetch etcd version: ", err)
-            return
+            return 500, {error_msg = err}

Review comment:
       Got it.




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