Skip to content

Commit

Permalink
Remove trailing period from SRV records (#7494)
Browse files Browse the repository at this point in the history
Recently ran into an issue with Istio in particular, where leaving the
trailing dot on the SRV record returned by `dnssrvnoa` lookups led to an
inability to connect to the endpoint. Removing the trailing dot fixes
this behaviour.

Now, technically, this is a valid URL, and it shouldn't be a problem.
One could definitely argue that Istio should be responsible here for
ensuring that the traffic is delivered. The problem seems rooted in how
Istio attempts to do wildcard matching or URLs it receives - including
the dot leads it to lookup an empty DNS field, which is invalid.

The approach I take here is actually copied from how Prometheus does it.
Therefore I hope we can sneak this through with the argument that 'this
is how Prometheus does it', regardless of whether or not this is
philosophically correct...

Signed-off-by: verejoel <[email protected]>
  • Loading branch information
verejoel authored Jul 9, 2024
1 parent 6f12454 commit fb76b22
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re

### Changed

- [#7494](https://github.com/thanos-io/thanos/pull/7494) Ruler: remove trailing period from SRV records returned by discovery `dnsnosrva` lookups

### Removed

## [v0.36.0](https://github.com/thanos-io/thanos/tree/release-0.36) - in progress
Expand Down
4 changes: 3 additions & 1 deletion pkg/discovery/dns/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ func (s *dnsSD) Resolve(ctx context.Context, name string, qtype QType) ([]string
}

if qtype == SRVNoA {
res = append(res, appendScheme(scheme, net.JoinHostPort(rec.Target, resPort)))
// Remove the final dot from rooted DNS names (this is for compatibility with Prometheus)
target := strings.TrimRight(rec.Target, ".")
res = append(res, appendScheme(scheme, net.JoinHostPort(target, resPort)))
continue
}
// Do A lookup for the domain in SRV answer.
Expand Down

0 comments on commit fb76b22

Please sign in to comment.