Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update kubernetai plugin to support transfers via the transfers plugin. #66

Merged
merged 1 commit into from
Sep 17, 2024

Conversation

davidmccormick
Copy link
Contributor

@davidmccormick davidmccormick commented Sep 5, 2024

The kubernetes plugin was updated to support a new transfer plugin for managing zone transfer requests:

see:-

coredns/coredns#2585 - plugin/etcd: support zone transfers #2585
coredns/coredns#3121 - plugin/transfer: New plugin for handling zone transfers #3121
coredns/coredns#3223 - plugin/transfer: Zone transfer plugin #3223

When this work was performed, the internal implementation of AXFR requests was removed from the kubernetes plugin and instead it supports the transfer.Transferer interface. kubernetai doesn't support the transfer.Transferer interface and so building CoreDNS v1.11.3 with this plugin results in AXFR requests failing to respond with the zones.

This PR adds a Transfer method to the Kubernetesai object so that it can broker AXFR requests to its embedded Kubernetes plugins.

In order to write tests, I have abstracted the Kubernetes plugin to a embeddedKubernetesPluginInterface. Which allows me to swap out the underlying Kubernetes plugin. This is neater than the podHandlerItf approach and allows for us to generate different responses from the embedded plugins needed to check the integration through kubernetes plugins.

This PR is also supported by integration tests in coredns/ci - coredns/ci#158

The kubernetai tests fail against master:

=== RUN   TestAXFR
=== RUN   TestAXFR/matches_stanza_1/test-4.svc.cluster.local._AXFR
    axfr_test.go:187: expected 1 query attempt, observed 0
    axfr_test.go:196: coredns log: .:53
        CoreDNS-1.11.3
        linux/arm64, go1.23.1, ce45312
        [INFO] 172.17.0.1:37727 - 13103 "AXFR IN test-4.svc.cluster.local. tcp 65 false 65535" - - 0 0.000046625s
=== RUN   TestAXFR/matches_stanza_2/test-5.svc.cluster.local._AXFR
    axfr_test.go:187: expected 1 query attempt, observed 0
    axfr_test.go:196: coredns log: .:53
        CoreDNS-1.11.3
        linux/arm64, go1.23.1, ce45312
        [INFO] 172.17.0.1:36319 - 63827 "AXFR IN test-5.svc.cluster.local. tcp 65 false 65535" - - 0 0.0000605s
=== RUN   TestAXFR/matches_first_stanza/cluster.local._AXFR
    axfr_test.go:187: expected 1 query attempt, observed 0
    axfr_test.go:196: coredns log: .:53
        CoreDNS-1.11.3
        linux/arm64, go1.23.1, ce45312
        [INFO] 172.17.0.1:57837 - 14074 "AXFR IN cluster.local. tcp 54 false 65535" - - 0 0.00003625s
--- FAIL: TestAXFR (9.17s)
    --- FAIL: TestAXFR/matches_stanza_1/test-4.svc.cluster.local._AXFR (3.09s)
    --- FAIL: TestAXFR/matches_stanza_2/test-5.svc.cluster.local._AXFR (3.11s)
    --- FAIL: TestAXFR/matches_first_stanza/cluster.local._AXFR (2.97s)
FAIL
FAIL	github.com/coredns/ci/test/kubernetai	24.938s
FAIL

Manual testing against this PR produces:

cd $GOPATH/src/github.com/coredns/ci && go mod tidy && go test -v ./test/kubernetai/... --run=TestAXFR                                                                                                                               
=== RUN   TestAXFR
=== RUN   TestAXFR/matches_stanza_1/test-4.svc.cluster.local._AXFR
=== RUN   TestAXFR/matches_stanza_2/test-5.svc.cluster.local._AXFR
=== RUN   TestAXFR/matches_first_stanza/cluster.local._AXFR
--- PASS: TestAXFR (8.59s)
    --- PASS: TestAXFR/matches_stanza_1/test-4.svc.cluster.local._AXFR (2.50s)
    --- PASS: TestAXFR/matches_stanza_2/test-5.svc.cluster.local._AXFR (3.01s)
    --- PASS: TestAXFR/matches_first_stanza/cluster.local._AXFR (3.08s)
PASS
ok      github.com/coredns/ci/test/kubernetai    9.297s 

Abstract the list of kubernetes plugins to an interface so that we can affectively mock them and control per plugin behaviour and responses.

Signed-off-by: Dave McCormick <[email protected]>
@davidmccormick davidmccormick marked this pull request as ready for review September 16, 2024 15:34
@davidmccormick
Copy link
Contributor Author

The test has passed because the AXFR test has yet to be merged - coredns/ci#158

@davidmccormick
Copy link
Contributor Author

If this PR is merged before #66 we should see the existing kubernetai plugin fail these tests because it doesn't support the transfer plugin.

@chrisohaver chrisohaver merged commit 6304267 into coredns:master Sep 17, 2024
5 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