Skip to content

Conversation

@ChuanFF
Copy link
Contributor

@ChuanFF ChuanFF commented Dec 31, 2025

Description

This pull request adds a Kubernetes service discovery readiness status query to the /status/ready interface. Specifically, the readiness check calls the check_discovery_ready method of the service discovery module. Other types of service discovery, such as Consul, can also adapt this method to support the service discovery module.

relate discuss:
#12635

Which issue(s) this PR fixes:

Fixes #

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Dec 31, 2025
if not endpoint_dict then
core.log.error("failed to get lua_shared_dict:", get_endpoint_dict_name(id),
", please check your APISIX version")
return false, "failed to get lua_shared_dict: ", get_endpoint_dict_name(id),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use .. for string concatenation.



local function post_list(handle)
handle.endpoint_dict:safe_set("discovery_ready",true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

safe_set lacks error handling

apisix/init.lua Outdated
end
end
end
return true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not use semicolons.

ngx.exit(200)
local http = require("resty.http")
local healthcheck_uri = "http://127.0.0.1:7085" .. "/status/ready"
for i = 1, 4 do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment explaining the rationale for selecting the number of retries.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

APISIX takes time to load data from the Kubernetes API server. In scenarios with small amounts of data, it may complete in less than 1 second. The maximum wait time I set, 5 seconds, is solely to account for network fluctuations.

@Baoyuantop Baoyuantop added the wait for update wait for the author's response in this issue/PR label Jan 4, 2026
@Baoyuantop Baoyuantop added awaiting review and removed wait for update wait for the author's response in this issue/PR labels Jan 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review enhancement New feature or request size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants