Skip to content

fix: DNS upstream healthcheck recreation with IP changes#12987

Closed
grapestore wants to merge 1 commit intoapache:masterfrom
grapestore:fix/dns-upstream-healthcheck-version-mismatch
Closed

fix: DNS upstream healthcheck recreation with IP changes#12987
grapestore wants to merge 1 commit intoapache:masterfrom
grapestore:fix/dns-upstream-healthcheck-version-mismatch

Conversation

@grapestore
Copy link

Description

This PR fixes an issue where the healthchecker was not created due to a version mismatch,
causing health checks for DNS-based upstreams to not work.

The mismatch occurred because parse_domain_in_up() modified modifiedIndex in memory,
while _nodes_ver was not persisted in the config.
As a result, fetch_checker and healthcheck_manager calculated different versions for the same upstream.

How to reproduce

  1. Configure an upstream with two DNS-based nodes.
  2. Enable active and passive health checks.
  3. Start APISIX.

Both active and passive health checks do not work because the healthchecker is not created.

This PR ensures that:

  • modifiedIndex remains unchanged
  • _nodes_ver is set with a timestamp when nodes are updated
  • _nodes_ver and updated nodes are persisted to the config

With these changes, both components calculate the same version and the healthchecker is created correctly.

Which issue(s) this PR fixes:

Fixes #

Checklist

  • 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

Problem:
When DNS resolution changes (test.com: 127.0.0.1 → 127.0.0.2),
healthchecker was not being recreated, causing health checks to fail
for DNS-based upstreams.

Root Cause:
- parse_domain_in_up() updated modifiedIndex with timestamp in memory
- However, _nodes_ver remained nil in stored config
- When fetch_checker calculated requested version:
  version = modifiedIndex (no timestamp) + _nodes_ver (nil) = no timestamp
- When healthcheck_manager calculated current version:
  version = modifiedIndex (with timestamp) + _nodes_ver (nil) = with timestamp
- Version mismatch prevented healthchecker creation

Solution:
1. Keep modifiedIndex as original (no timestamp modification)
2. Set _nodes_ver with timestamp when IP changes: '#1770398721.88'
3. Persist to config: resource.set_nodes_ver_and_nodes()
4. Both places now calculate: modifiedIndex + _nodes_ver correctly

Result:
- requested_version: '53#1770398721.88' ✅
- current_version: '53#1770398721.88' ✅
- Versions match → healthchecker recreated on DNS IP change
@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. bug Something isn't working labels Feb 6, 2026
@grapestore grapestore closed this Feb 6, 2026
@grapestore grapestore deleted the fix/dns-upstream-healthcheck-version-mismatch branch February 6, 2026 17:44
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:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant