Skip to content

[BUG] plugin/ready: fix Reset list of readiness plugins#8035

Merged
thevilledev merged 1 commit into
coredns:masterfrom
yangjunmyfm192085:fixreadiness
Apr 11, 2026
Merged

[BUG] plugin/ready: fix Reset list of readiness plugins#8035
thevilledev merged 1 commit into
coredns:masterfrom
yangjunmyfm192085:fixreadiness

Conversation

@yangjunmyfm192085

@yangjunmyfm192085 yangjunmyfm192085 commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

1. Why is this pull request needed and what does it do?

When the Corefile contains multiple server blocks and each block enables the ready directive, the readiness check from the kubernetes plugin is overwritten by plugins from subsequent blocks (e.g. erratic). As a result, the /ready endpoint only reports the readiness status of the last plugin in the list.

Reproduction Corefile:

apiVersion: v1
kind: ConfigMap
data:
  Corefile: |
    cluster.local.:53 {
        ready
        kubernetes cluster.local {
            ...
        }
        reload
        ...
    }

    .:53 {
        ready
        reload
        ...
        erratic
        forward . xx.xx.xx.xx
    }

In the above configuration, querying the readiness endpoint (/ready) only checks the erratic plugin. The kubernetes plugin's readiness check is completely overwritten.
Root Cause:
The plugin/ready package collects plugins that implement the readiness interface into a list. However, the logic responsible for resetting this list (especially during configuration reload or when initializing multiple server blocks) was incorrect. The reset was not properly performed, causing later plugins to overwrite earlier ones. In the end, only the last registered readiness plugin remained in the list.
Fix:

Correct the reset logic of the readiness plugin list in plugin/ready.
Ensure that the list is properly cleared and repopulated on every reload and during initialization of multiple server blocks.
After this fix, readiness checks from all plugins (including kubernetes and erratic) in different server blocks will be respected and combined correctly.

2. Which issues (if any) are related?

3. Which documentation changes (if any) need to be made?

4. Does this introduce a backward incompatible change or deprecation?

@yangjunmyfm192085

Copy link
Copy Markdown
Contributor Author

Hi @miekg @yongtang,

I have open the PR with a fix for the readiness plugin list reset issue when using multiple server blocks.

Summary of the bug:
When ready is enabled in multiple server blocks (common in Kubernetes setups with a cluster.local block + root . block), the readiness checks from earlier plugins (especially the kubernetes plugin) get overwritten by later ones (e.g. erratic). As a result, the /ready endpoint only checks the last plugin.

This PR corrects the reset logic in plugin/ready so that the list of readiness plugins is properly cleared and repopulated on reload and during multi-block initialization. After the fix, all readiness checks across server blocks are correctly combined.

The change is small and targeted. I have tested it with the multi-block Corefile scenario, and readiness now behaves as expected even after reloads.

Could you please take a look and review this PR? I would really appreciate it if you could approve the change so we can get this bug fixed and merged.

Thanks!

@thevilledev thevilledev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The fix itself looks correct. What's missing is a regression test for the multi-server-block scenario it's fixing. There's already a similar e2e test in test/reload_test.go called TestReloadUnreadyPlugin. I think a new test should follow the same pattern but with (at least) two server blocks. Could you add a test?

@yangjunmyfm192085

Copy link
Copy Markdown
Contributor Author

Hi, @thevilledev I've added the corresponding e2e test cases as requested. Could you please take another look and review it again?
Thank you!

Comment thread test/reload_test.go Outdated
Comment thread plugin/ready/list.go
Signed-off-by: 杨军10092085 <yang.jun22@zte.com.cn>
@yangjunmyfm192085

Copy link
Copy Markdown
Contributor Author

I've made the changes as suggested. Would you mind taking another look? @thevilledev

@thevilledev thevilledev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM, thanks @yangjunmyfm192085!

@thevilledev thevilledev merged commit 57a95e2 into coredns:master Apr 11, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants