-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat: kubernetes discovery readiness check #12852
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…hcheck # Conflicts: # apisix/discovery/kubernetes/init.lua
apisix/discovery/kubernetes/init.lua
Outdated
| 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), |
There was a problem hiding this comment.
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.
apisix/discovery/kubernetes/init.lua
Outdated
|
|
||
|
|
||
| local function post_list(handle) | ||
| handle.endpoint_dict:safe_set("discovery_ready",true) |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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_readymethod 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