janiussyafiq opened a new pull request, #13903:
URL: https://github.com/apache/apisix/pull/13903

   ### Description
   
   When an upstream uses a domain name in `nodes`, a transient DNS failure 
(timeout, SERVFAIL) during periodic re-resolution dropped the node from the 
resolved node list.
   When DNS recovered moments later, the node was re-added.
   That drop/re-add changes the node list, which rebuilds the health checker, 
and a re-added target always starts as healthy.
   As a result, a node that active checks had correctly marked unhealthy 
received traffic again without passing any recovery probe, and workers could 
disagree about its state because each of them resolves independently.
   
   The DNS failure says nothing about the backend's health, so it should not 
destroy the health checker's state.
   
   This PR:
   
   - returns the DNS rcode from `core.dns.client.resolve()` / 
`core.resolver.parse_domain()` as a third value, so callers can tell an 
authoritative NXDOMAIN answer apart from a query that could not be completed at 
all
   - on a failed query that is not NXDOMAIN, keeps the node at its last 
resolved address instead of dropping it: the node list stays stable, the 
checker target survives, and the unhealthy state is preserved while probes keep 
running
   - on an authoritative NXDOMAIN, still removes the node, since the server 
positively stated the name no longer exists
   - makes `sort_by_key_host` tie-break on port, so two nodes sharing one IP 
cannot sort unstably and report a phantom node change
   
   Verified against an end-to-end reproduction (3-node upstream, one node 
failing its health endpoint, DNS server blipped for 8 seconds): without the fix 
the unhealthy node returns to rotation on all workers after the blip; with the 
fix it receives no traffic and stays unhealthy.
   
   #### Which issue(s) this PR fixes:
   
   Fixes #13888
   
   ### Checklist
   
   - [x] I have explained the need for this PR and the problem it solves
   - [x] I have explained the changes or the new features added to this PR
   - [x] I have added tests corresponding to this change
   - [ ] I have updated the documentation to reflect this change
   - [x] I have verified that this change is backward compatible (If not, 
please discuss on the [APISIX mailing 
list](https://github.com/apache/apisix/tree/master#community) first)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to