fix(ai-proxy-multi): resolve _dns_value in construct_upstream when nil#13322
Merged
nic-6443 merged 3 commits intoApr 30, 2026
Merged
Conversation
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.
5fb4645 to
4427ef8
Compare
There was a problem hiding this comment.
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_valueisnilinconstruct_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.
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.
4427ef8 to
6389779
Compare
AlinsRan
approved these changes
Apr 30, 2026
membphis
approved these changes
Apr 30, 2026
Baoyuantop
approved these changes
Apr 30, 2026
shreemaan-abhishek
approved these changes
Apr 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the config store replaces the config table (e.g.
modifiedIndexincremented), the runtime_dns_valuefield is lost because it lived on the old table. This causesconstruct_upstream()to return an error during periodic health check validation intimer_working_pool_check(), logging a noisy warning:The fix calls
resolve_endpoint()as fallback when_dns_valueis nil. This is safe because: