Skip to content

fix(ai-proxy-multi): resolve _dns_value in construct_upstream when nil#13322

Merged
nic-6443 merged 3 commits into
apache:masterfrom
nic-6443:fix/ai-proxy-multi-healthcheck-warning
Apr 30, 2026
Merged

fix(ai-proxy-multi): resolve _dns_value in construct_upstream when nil#13322
nic-6443 merged 3 commits into
apache:masterfrom
nic-6443:fix/ai-proxy-multi-healthcheck-warning

Conversation

@nic-6443
Copy link
Copy Markdown
Member

When the config store replaces the config table (e.g. modifiedIndex incremented), the runtime _dns_value field is lost because it lived on the old table. This causes construct_upstream() to return an error during periodic health check validation in timer_working_pool_check(), logging a noisy warning:

[checking checker] unable to construct upstream for plugin: ai-proxy-multi ...

The fix calls resolve_endpoint() as fallback when _dns_value is nil. This is safe because:

  • The DNS resolver has TTL-based caching (microsecond-level cache hit)
  • This path only triggers after config table replacement, not every check tick
  • The checker will still be destroyed via version mismatch — the only difference is it takes the clean path instead of the error path

When CP pushes a config update, config_etcd replaces the entire config
table, causing the runtime _dns_value field to be lost. This made
construct_upstream() return an error during periodic health check
validation, logging a noisy warning.

Fix by calling resolve_endpoint() as fallback when _dns_value is nil.
This is safe because the DNS resolver has TTL-based caching, and this
path only triggers after config table replacement.
Copilot AI review requested due to automatic review settings April 29, 2026 14:55
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. bug Something isn't working labels Apr 29, 2026
@nic-6443 nic-6443 force-pushed the fix/ai-proxy-multi-healthcheck-warning branch from 5fb4645 to 4427ef8 Compare April 29, 2026 15:13
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Fixes a regression where _dns_value can be lost after config table replacement, causing construct_upstream() (and related health-check validation) to error noisily instead of re-resolving the endpoint.

Changes:

  • Resolve endpoint as a fallback when instance._dns_value is nil in construct_upstream().
  • Add similar fallback resolution in health-check instance processing to avoid nil dereferences/noisy failures.
  • Add a regression test covering the construct_upstream() fallback behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
apisix/plugins/ai-proxy-multi.lua Adds fallback resolve_endpoint() calls when _dns_value is missing (construct + health-check path).
t/plugin/ai-proxy-multi3.t Adds a regression test simulating config table replacement where _dns_value is lost.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread t/plugin/ai-proxy-multi3.t
Comment thread t/plugin/ai-proxy-multi3.t
Comment thread apisix/plugins/ai-proxy-multi.lua Outdated
Comment thread apisix/plugins/ai-proxy-multi.lua Outdated
Comment thread apisix/plugins/ai-proxy-multi.lua Outdated
Comment thread apisix/plugins/ai-proxy-multi.lua
Add defensive resolve_endpoint() fallback in fetch_health_instances()
where _dns_value is accessed for health check target status. If
resolution fails, treat the instance as healthy to avoid dropping
traffic.
@nic-6443 nic-6443 force-pushed the fix/ai-proxy-multi-healthcheck-warning branch from 4427ef8 to 6389779 Compare April 29, 2026 16:03
f
Signed-off-by: Nic <qianyong@api7.ai>
@nic-6443 nic-6443 merged commit 4762c33 into apache:master Apr 30, 2026
19 checks passed
@nic-6443 nic-6443 deleted the fix/ai-proxy-multi-healthcheck-warning branch April 30, 2026 04:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants