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

Fix flaky dns test #6923

Merged
merged 1 commit into from
Apr 22, 2024
Merged

Conversation

inteon
Copy link
Member

@inteon inteon commented Apr 20, 2024

Example flake: https://prow.infra.cert-manager.io/view/gs/cert-manager-prow-artifacts/logs/ci-cert-manager-master-make-test/1781654108378238976

Master:

$ go test -count=100 -timeout 30s -run ^TestReachabilityCustomDnsServers$ github.com/cert-manager/cert-manager/pkg/issuer/acme/http
--- FAIL: TestReachabilityCustomDnsServers (0.12s)
    http_test.go:189: Unexpected error: failed to perform self check GET request 'https://cert-manager.io': Get "https://cert-manager.io": dial tcp: lookup cert-manager.io on 127.0.0.53:53: read udp 127.0.0.1:54187->127.0.0.1:15353: read: connection refused
--- FAIL: TestReachabilityCustomDnsServers (0.11s)
    http_test.go:189: Unexpected error: failed to perform self check GET request 'https://cert-manager.io': Get "https://cert-manager.io": dial tcp: lookup cert-manager.io on 127.0.0.53:53: read udp 127.0.0.1:43837->127.0.0.1:15353: read: connection refused
--- FAIL: TestReachabilityCustomDnsServers (0.11s)
    http_test.go:189: Unexpected error: failed to perform self check GET request 'https://cert-manager.io': Get "https://cert-manager.io": dial tcp: lookup cert-manager.io on 127.0.0.53:53: read udp 127.0.0.1:50259->127.0.0.1:15353: read: connection refused
--- FAIL: TestReachabilityCustomDnsServers (0.11s)
    http_test.go:189: Unexpected error: failed to perform self check GET request 'https://cert-manager.io': Get "https://cert-manager.io": dial tcp: lookup cert-manager.io on 127.0.0.53:53: read udp 127.0.0.1:35645->127.0.0.1:15353: read: connection refused
--- FAIL: TestReachabilityCustomDnsServers (0.11s)
    http_test.go:189: Unexpected error: failed to perform self check GET request 'https://cert-manager.io': Get "https://cert-manager.io": dial tcp: lookup cert-manager.io on 127.0.0.53:53: read udp 127.0.0.1:46554->127.0.0.1:15353: read: connection refused
FAIL
FAIL    github.com/cert-manager/cert-manager/pkg/issuer/acme/http       20.767s
FAIL

This PR:

$ go test -count=100 -timeout 30s -run ^TestReachabilityCustomDnsServers$ github.com/cert-manager/cert-manager/pkg/issuer/acme/http
ok      github.com/cert-manager/cert-manager/pkg/issuer/acme/http       21.122s

Kind

/kind flake

Release Note

NONE

@cert-manager-prow cert-manager-prow bot added release-note-none Denotes a PR that doesn't merit a release note. kind/flake Categorizes issue or PR as related to a flaky test. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. area/acme Indicates a PR directly modifies the ACME Issuer code area/acme/http01 Indicates a PR modifies ACME HTTP01 provider code labels Apr 20, 2024
go server.ListenAndServe()

go func() {
if err := server.ListenAndServe(); err != nil {
Copy link
Member Author

Choose a reason for hiding this comment

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

Unrelated change: don't silently fail ListenAndServe, fail test instead.

@inteon
Copy link
Member Author

inteon commented Apr 22, 2024

/cherrypick release-1.12

@cert-manager-bot
Copy link
Contributor

@inteon: once the present PR merges, I will cherry-pick it on top of release-1.12 in a new PR and assign it to you.

In response to this:

/cherrypick release-1.12

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@inteon
Copy link
Member Author

inteon commented Apr 22, 2024

/cherrypick release-1.13

@cert-manager-bot
Copy link
Contributor

@inteon: once the present PR merges, I will cherry-pick it on top of release-1.13 in a new PR and assign it to you.

In response to this:

/cherrypick release-1.13

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@inteon
Copy link
Member Author

inteon commented Apr 22, 2024

/cherrypick release-1.14

@cert-manager-bot
Copy link
Contributor

@inteon: once the present PR merges, I will cherry-pick it on top of release-1.14 in a new PR and assign it to you.

In response to this:

/cherrypick release-1.14

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link
Contributor

@ThatsMrTalbot ThatsMrTalbot left a comment

Choose a reason for hiding this comment

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

Can you explain how using our own Mux fixes things compared to the DefaultServeMux?

@inteon inteon marked this pull request as draft April 22, 2024 12:45
@cert-manager-prow cert-manager-prow bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 22, 2024
…equests

Signed-off-by: Tim Ramlot <42113979+inteon@users.noreply.github.com>
@inteon inteon marked this pull request as ready for review April 22, 2024 12:58
@cert-manager-prow cert-manager-prow bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 22, 2024
dnsServerCalled := int32(0)

server := &dns.Server{Addr: "127.0.0.1:15353", Net: "udp"}
server := &dns.Server{Addr: "127.0.0.1:15353", Net: "udp", NotifyStartedFunc: func() { close(dnsServerStarted) }}
Copy link
Member Author

Choose a reason for hiding this comment

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

We received a read: connection refused error when the test started before the DNS server was started.

defer server.Shutdown()

dns.HandleFunc(".", func(w dns.ResponseWriter, r *dns.Msg) {
mux := &dns.ServeMux{}
Copy link
Member Author

Choose a reason for hiding this comment

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

We create a new mux here instead of using the default/ global mux, so that we cannot interfere with other mux registrations (in other tests or when running this test in parallel).

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we can run in parallel since we use a fixed port for the DNS server, but I can see how we would want to reset the state between tests.

@inteon
Copy link
Member Author

inteon commented Apr 22, 2024

Can you explain how using our own Mux fixes things compared to the DefaultServeMux?

Thanks for the comment, I actually hadn't fixed the test completely yet.
I now fixed the flake and added a proof in the description.
I also added a few code comments to explain why the changes were made.

@ThatsMrTalbot
Copy link
Contributor

Ah, so the main fix was the new channel we wait on to ensure the DNS server is up and running. That makes sense to me.
/lgtm

@cert-manager-prow cert-manager-prow bot added the lgtm Indicates that a PR is ready to be merged. label Apr 22, 2024
@inteon
Copy link
Member Author

inteon commented Apr 22, 2024

/retest

@inteon
Copy link
Member Author

inteon commented Apr 22, 2024

/approve

@cert-manager-prow
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: inteon

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@cert-manager-prow cert-manager-prow bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 22, 2024
@cert-manager-prow cert-manager-prow bot merged commit 2ca75cc into cert-manager:master Apr 22, 2024
6 checks passed
@cert-manager-bot
Copy link
Contributor

@inteon: new pull request created: #6934

In response to this:

/cherrypick release-1.12

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@cert-manager-bot
Copy link
Contributor

@inteon: new pull request created: #6935

In response to this:

/cherrypick release-1.13

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@cert-manager-bot
Copy link
Contributor

@inteon: new pull request created: #6936

In response to this:

/cherrypick release-1.14

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/acme/http01 Indicates a PR modifies ACME HTTP01 provider code area/acme Indicates a PR directly modifies the ACME Issuer code dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. kind/flake Categorizes issue or PR as related to a flaky test. lgtm Indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants