bzp2010 commented on code in PR #12200: URL: https://github.com/apache/apisix/pull/12200#discussion_r2097281395
########## apisix/core/config_etcd.lua: ########## @@ -29,17 +29,20 @@ local core_str = require("apisix.core.string") local new_tab = require("table.new") local inspect = require("inspect") local errlog = require("ngx.errlog") +local process = require("ngx.process") local log_level = errlog.get_sys_filter_level() local NGX_INFO = ngx.INFO local check_schema = require("apisix.core.schema").check local exiting = ngx.worker.exiting +local worker_id = ngx.worker.id Review Comment: ```suggestion local worker_id = ngx.worker.id ``` ########## apisix/core/config_yaml.lua: ########## @@ -73,6 +75,19 @@ local apisix_yaml local apisix_yaml_raw -- save a deepcopy of the latest configuration for API local apisix_yaml_mtime +local function sync_status_to_shdict(status) + if process.type() ~= "worker" then + return + end + local status_shdict = ngx.shared[status_report_shared_dict_name] + if not status_shdict then + return + end + local id = worker_id() + log.info("sync status to shared dict, pid: ", id, " status: ", status) Review Comment: pid => worker id ########## apisix/init.lua: ########## @@ -868,6 +869,54 @@ local function healthcheck_passive(api_ctx) end +function _M.status() + core.response.exit(200, core.json.encode({ + status = "ok" }), + { ["Content-Type"] = "application/json" + }) +end + +function _M.status_ready() + local local_conf = core.config.local_conf() + local role = core.table.try_read_attr(local_conf, "deployment", "role") + local provider = core.table.try_read_attr(local_conf, "deployment", "role_" .. role, "config_provider") + if provider == "yaml" or provider == "etcd" then + local status_shdict = ngx.shared["status-report"] + local ids = status_shdict:get_keys() + local errors = {} + Review Comment: If the `ids` length is not equal to `ngx.worker.count`, it should also be reported as unhealthy. Note that worker ID start at 0. -- 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