-
Notifications
You must be signed in to change notification settings - Fork 2.6k
help request: upstream support retry on http custom code #12127
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
Comments
i mean when get 500/501/502/503 and the method is "GET" or custom http method config, the apisix will hold the request and retry the upstream for tiny network unreachable or sth else. |
Yeah this can be done. We can add an optional field local core = require("apisix.core")
local plugin_name = "retry-control"
local schema = {
type = "object",
properties = {
non_retry_statuses = {
type = "array",
items = { type = "integer" },
default = { 404, 412 } -- Example: Don't retry on these statuses
}
}
}
local _M = {
version = 1.0,
priority = 999, -- Set appropriate priority
name = plugin_name,
schema = schema,
}
function _M.check_schema(conf)
return core.schema.check(schema, conf)
end
function _M.before_proxy(conf, ctx)
-- Only execute during retries
if not ctx.picked_server then
local state, code = get_last_failure()
-- Check if status code is in non-retry list
if code and core.table.has_value(conf.non_retry_statuses, code) then
core.log.warn("Aborting retry due to status code: ", code)
ctx.proxy_retry_deadline = ngx_now() -- Force retry timeout
end
end
return true
end
return _M |
@Revolyssup thank you so much for attention,but i have some questions:
Massive thanks for volunteering your skills! 🚀 |
|
@Revolyssup |
Description
for now,upstream admin api support retries and retry_timeout, can it support when http code such as 500/501/502/50x, do the retry thing?
i write a plugin code, but not include the real retry thing:
Environment
apisix version
): v3.2.2The text was updated successfully, but these errors were encountered: