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



##########
File path: apisix/plugins/server-info.lua
##########
@@ -158,25 +150,70 @@ local function report(premature, report_ttl)
         end
     end
 
-    server_info.last_report_time = ngx_time()
-
+    -- get inside etcd data, if not exist, create it
     local key = "/data_plane/server_info/" .. server_info.id
-    local ok, err = core.etcd.set(key, server_info, report_ttl)
+    local res, err = core.etcd.get(key)
+    if err ~= nil then
+        core.log.error("failed to get server_info from etcd: ", err)
+    end
+
+    if  not res.body.node then
+        local newres, err = core.etcd.set(key, server_info, report_ttl)
+        if not newres then
+            core.log.error("failed to set server_info: ", err)
+            return
+        end
+
+        -- set lease_id to ngx dict
+        local _, err = internal_status:set("lease_id", newres.body.lease_id)
+        if err ~= nil then
+            core.log.error("failed to save boot_time to shdict: ", err)

Review comment:
       Thanks for your carefulness.




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

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


Reply via email to