Skip to content

Commit

Permalink
trim the suffix dot from the srv.Target for etcd-client DNS lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
ahrtr committed Feb 18, 2022
1 parent e814f6f commit 09038ea
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG/CHANGELOG-3.6.md
Expand Up @@ -16,6 +16,7 @@ See [code changes](https://github.com/etcd-io/etcd/compare/v3.5.0...v3.6.0).

- Add command to generate [shell completion](https://github.com/etcd-io/etcd/pull/13133).
- When print endpoint status, [show db size in use](https://github.com/etcd-io/etcd/pull/13639)
- [Trim the suffix dot from the target](https://github.com/etcd-io/etcd/pull/13712) in SRV records returned by DNS lookup.

### etcdutl v3

Expand Down
3 changes: 2 additions & 1 deletion client/pkg/srv/srv.go
Expand Up @@ -106,9 +106,10 @@ func GetClient(service, domain string, serviceName string) (*SRVClients, error)
return err
}
for _, srv := range addrs {
shortHost := strings.TrimSuffix(srv.Target, ".")
urls = append(urls, &url.URL{
Scheme: scheme,
Host: net.JoinHostPort(srv.Target, fmt.Sprintf("%d", srv.Port)),
Host: net.JoinHostPort(shortHost, fmt.Sprintf("%d", srv.Port)),
})
}
srvs = append(srvs, addrs...)
Expand Down
6 changes: 3 additions & 3 deletions client/pkg/srv/srv_test.go
Expand Up @@ -226,9 +226,9 @@ func TestSRVDiscover(t *testing.T) {
},
{
[]*net.SRV{
{Target: "a.example.com", Port: 2480},
{Target: "b.example.com", Port: 2480},
{Target: "c.example.com", Port: 2480},
{Target: "a.example.com.", Port: 2480},
{Target: "b.example.com.", Port: 2480},
{Target: "c.example.com.", Port: 2480},
},
[]*net.SRV{},
[]string{"https://a.example.com:2480", "https://b.example.com:2480", "https://c.example.com:2480"},
Expand Down

0 comments on commit 09038ea

Please sign in to comment.