Skip to content

feat(ai-proxy-multi): add support for healthcheck#12509

Merged
Revolyssup merged 18 commits into
apache:masterfrom
Revolyssup:revolyssup/ai-proxy
Aug 21, 2025
Merged

feat(ai-proxy-multi): add support for healthcheck#12509
Revolyssup merged 18 commits into
apache:masterfrom
Revolyssup:revolyssup/ai-proxy

Conversation

@Revolyssup

@Revolyssup Revolyssup commented Aug 11, 2025

Copy link
Copy Markdown
Contributor

Checklist

Add healthcheck logic to faciilitate the selection of healthy ai backend while using ai-proxy-multi plugin.

Healthcheck manager has been modified with the capability to use dynamically created upstreams via the resource key.
For eg: if resource key is : /routes/1#<path to configuration>, the the configuration will be passed to the construct_upstream function implemented by the plugin to create an upstream instead of trying to simply extract from resource. This helps to leverage the healthcheck manager for use in ai-proxy and even traffic-split plugin as the healthcheck creation/management is decoupled from the routes or services(parent).

  • 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)

@Revolyssup
Revolyssup marked this pull request as draft August 11, 2025 08:47
@dosubot dosubot Bot added size:XXL This PR changes 1000+ lines, ignoring generated files. enhancement New feature or request labels Aug 11, 2025
@Revolyssup
Revolyssup marked this pull request as ready for review August 11, 2025 17:48
Comment thread apisix/plugin.lua Outdated
if not plugin_conf._meta.parent then
local mt_table = getmetatable(plugin_conf._meta)
if mt_table then
mt_table.parent = parent

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

#12426

this PR has beed merge

so the parent should be a resource path, do you think?

@Revolyssup Revolyssup Aug 12, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

the healthcheck_manager module is tied only to manage the checkers on the upstream configuration. I don't know if we can use that mechanism here because here we are creating custom healthchecker using the checks configuration in the plugin configuration.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

yes, i think we have to use the healthcheck_manager way

the old way parent is bad way which was deprecated

@Revolyssup
Revolyssup requested a review from membphis August 12, 2025 11:03
Comment thread apisix/healthcheck_manager.lua
@membphis
membphis requested review from bzp2010 and moonming August 12, 2025 12:04
Comment thread apisix/healthcheck_manager.lua Outdated
local function fetch_latest_conf(resource_path)
-- if resource path contains json path, extract out the prefix
-- for eg: extracts /routes/1 from /routes/1#plugins.abc
resource_path = resource_path:match("^(.-)#") or resource_path

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

use local res = ngx.re.split(...)

the res[1] is resource path, res[2] is sub resource path

we can add a new function to parse the path

Comment thread apisix/healthcheck_manager.lua Outdated
local plugin_name = get_plugin_name(resource_path)
if plugin_name and plugin_name ~= "" then
local json_path = "$." .. (resource_path:match("#(.+)$") or "")
local tab = jp.value(res_conf.value, json_path)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

need a meaning name

Comment thread apisix/plugin.lua
Comment thread apisix/plugin.lua
@Revolyssup
Revolyssup merged commit 8bb6802 into apache:master Aug 21, 2025
23 checks passed
@Revolyssup
Revolyssup deleted the revolyssup/ai-proxy branch August 21, 2025 05:20
jizhuozhi pushed a commit to jizhuozhi/apisix that referenced this pull request Oct 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants