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

Trim the suffix dot from the srv.Target for etcd-client DNS lookup #13712

Merged
merged 1 commit into from Feb 18, 2022

Conversation

ahrtr
Copy link
Member

@ahrtr ahrtr commented Feb 17, 2022

Usually the SRV records returned by DNS lookup have a trailing dot but URL shouldn't, so we should trim the suffix dot. We have already trimmed the suffix dot when bootstrapping etcd server ( see srv.go#L72 ), but not for etcd client.

cc @serathius @spzala @ptabor

@codecov-commenter
Copy link

codecov-commenter commented Feb 17, 2022

Codecov Report

Merging #13712 (09038ea) into main (e814f6f) will decrease coverage by 0.07%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #13712      +/-   ##
==========================================
- Coverage   72.85%   72.78%   -0.08%     
==========================================
  Files         465      465              
  Lines       37880    37881       +1     
==========================================
- Hits        27599    27573      -26     
- Misses       8508     8538      +30     
+ Partials     1773     1770       -3     
Flag Coverage Δ
all 72.78% <ø> (-0.08%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
server/etcdserver/api/v3rpc/watch.go 83.55% <0.00%> (-4.37%) ⬇️
server/storage/mvcc/watchable_store.go 85.86% <0.00%> (-3.27%) ⬇️
client/v3/leasing/cache.go 88.88% <0.00%> (-2.78%) ⬇️
server/etcdserver/api/rafthttp/msgappv2_codec.go 71.30% <0.00%> (-1.74%) ⬇️
server/proxy/grpcproxy/watch.go 95.37% <0.00%> (-1.16%) ⬇️
server/etcdserver/api/v3rpc/interceptor.go 76.56% <0.00%> (-1.05%) ⬇️
client/v3/leasing/kv.go 90.36% <0.00%> (-1.00%) ⬇️
server/proxy/grpcproxy/lease.go 88.23% <0.00%> (-0.91%) ⬇️
client/v3/watch.go 93.37% <0.00%> (-0.41%) ⬇️
server/etcdserver/server.go 85.08% <0.00%> (-0.24%) ⬇️
... and 6 more

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 e814f6f...09038ea. Read the comment docs.

Copy link
Member

@spzala spzala left a comment

Choose a reason for hiding this comment

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

@ahrtr thanks, please see inline comment.

CHANGELOG/CHANGELOG-3.6.md Outdated Show resolved Hide resolved
@ahrtr ahrtr force-pushed the correct_dns_etcd_client branch 2 times, most recently from 9958bf0 to 09038ea Compare February 18, 2022 05:19
@ahrtr
Copy link
Member Author

ahrtr commented Feb 18, 2022

@ahrtr thanks, please see inline comment.

Thanks for the quick review, resolved.

@ahrtr
Copy link
Member Author

ahrtr commented Feb 18, 2022

Resolved all comments, PTAL @serathius

@@ -106,9 +106,10 @@ func GetClient(service, domain string, serviceName string) (*SRVClients, error)
return err
}
for _, srv := range addrs {
shortHost := strings.TrimSuffix(srv.Target, ".")
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought the trailing dot meant the dns name was canonical and shouldn't have dns search paths appended to it. Does trimming the dot mean local dns search paths are used and the resolved address could end up being different?

Copy link
Member Author

Choose a reason for hiding this comment

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

If you keep reading the following couple of lines of code, you will find we just trim the trailing dot when constructing the network address.

Copy link
Contributor

Choose a reason for hiding this comment

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

if the SRV records are being returned with trailing dots, and we're turning that into client URLs without trailing dots, doesn't that mean DNS search paths are used to resolve those URLs to IPs, contrary to what the trailing dot in the srv record indicated?

Copy link
Member Author

Choose a reason for hiding this comment

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

The addrs is already the results of dns lookup. The urls/endpoints will be delivered to gRPC

Copy link
Contributor

Choose a reason for hiding this comment

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

won't a second DNS lookup be done to resolve the hostnames to IPs? don't we still need the trailing . to make that DNS resolution avoid using locally configured DNS search paths?

Copy link
Contributor

Choose a reason for hiding this comment

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

I verified this change is incorrect, opened #13948 with details of the implications for DNS lookup.

Copy link
Contributor

@liggitt liggitt Apr 15, 2022

Choose a reason for hiding this comment

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

revert opened in #13949 (and revert of the 3.5 pick opened in #13950)

Copy link
Contributor

Choose a reason for hiding this comment

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

that also probably might mean the server-side SRV record transformation this was based on is incorrect -

shortHost := strings.TrimSuffix(srv.Target, ".")
is probably worth revisiting

Copy link
Member Author

Choose a reason for hiding this comment

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

Please see my response in 13948#issuecomment-1100588121)

{Target: "a.example.com", Port: 2480},
{Target: "b.example.com", Port: 2480},
{Target: "a.example.com.", Port: 2480},
{Target: "b.example.com.", Port: 2480},
{Target: "c.example.com", Port: 2480},
},
[]*net.SRV{},
Copy link
Contributor

Choose a reason for hiding this comment

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

this unit test is a good example of what looks incorrect at first glance... with a client connection of []string{"https://a.example.com:2480", "https://b.example.com:2480", "https://c.example.com:2480"}, won't local DNS search paths be attempted for these URLs (depending on ndots settings)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants