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

Retry other external DNS servers on ServFail #2121

Merged
merged 1 commit into from
Mar 23, 2018
Merged

Conversation

ddebroy
Copy link
Contributor

@ddebroy ddebroy commented Mar 20, 2018

This PR covers the following:

  1. Implements fix for DNS resovler should continue on SERVFAIL #1664
  2. Fixes a reference to members of resp outside null check that may lead to a null exception.
  3. Unit tests involving a local DNS server that can be expanded and programmed to cover external DNS tests.

@fcrisciani
Copy link

Misspell error :)

./resolver_test.go:267:56: "begining" is a misspelling of "beginning"

@codecov-io
Copy link

codecov-io commented Mar 20, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@2bf6330). Click here to learn what that means.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #2121   +/-   ##
=========================================
  Coverage          ?   40.49%           
=========================================
  Files             ?      139           
  Lines             ?    22436           
  Branches          ?        0           
=========================================
  Hits              ?     9086           
  Misses            ?    12010           
  Partials          ?     1340
Impacted Files Coverage Δ
resolver.go 50.84% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2bf6330...6317705. Read the comment docs.

Copy link
Contributor

@ctelfer ctelfer left a comment

Choose a reason for hiding this comment

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

LGTM

Looks correct overall. Just a minor suggestion w.r.t. the test code. Feel free to ignore.

resolver_test.go Outdated
m.SetRcode(r, dns.RcodeServerFailure)
}
requests = requests + 1
w.WriteMsg(m)
Copy link
Contributor

Choose a reason for hiding this comment

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

The global state here and the comparison against it seems a little odd. The way TestDNSProxyServFail below compared "requests" w/ the previous value threw me at first. Take it for what it's worth, but suggest:

func newHandleTestDNSRequestServFailOnce(requests *int) func(dns.ResponseWriter, dns.*Msg) {
	return func(w dns.ResponseWriter, r *dns.Msg) {
		...
		*requests = *requests + 1
		...
	}
}
...
func TestDNSProxyServFail(t *testing.T) {
...
   var nRequests int = 0
   dns.HandleFunc(".", newHandleTestDNSRequestServFailOnce(&nRequests))
...
   if nRequests != 2 {
...
   }
...
}

Just thought it might help readability. (One could also embed the whole newHandleTestDNSRequestServFailOnce() body in the main test function and not have to pass the request counter pointer.... but that seems uglier, really.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestion! I did not like that global either and your suggestion is a decent way to keep it bound to the scope of the function. Will incorporate it.

Choose a reason for hiding this comment

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

+1 to this

resolver_test.go Outdated
if tconn != nil {
defer tconn.Close()
}
if err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we club both if together ? it will help readability. Else block seems to be more. Just a suggestion .
LIke

Copy link
Collaborator

Choose a reason for hiding this comment

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

LGTM

Signed-off-by: Deep Debroy <ddebroy@docker.com>
@ddebroy
Copy link
Contributor Author

ddebroy commented Mar 23, 2018

Incorporated code review comments.

Copy link

@fcrisciani fcrisciani left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@ctelfer ctelfer left a comment

Choose a reason for hiding this comment

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

Adjustment LGTM. Thanks!

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.

5 participants