Skip to content

Commit

Permalink
Previously addressing feedback in my PR to introduce a Kafka/Admin AP…
Browse files Browse the repository at this point in the history
…I client constructor into this repo, I refactored the URL construction code to leverage the same internal helper that constructs URLs with the InternalDomain helper: (#1493)

91fa8c1

Doing this exposed two things:

1. We use an "empty label" trailing dot for our internal domains (https://github.com/redpanda-data/helm-charts/blob/aca43d8bd857e9d41e68269765fa84f68774203e/charts/redpanda/helpers.go#L136)
2. We weren't handling that in the FQDN parsing code that I had added for our dialer.

As a result, when I tried to tie these two pieces of code together with the introduction of a client factory in our operator repo, anything using a Redpanda cluster reference to initialize a client failed with an "invalid FQDN" error. This fixes that and supports the perfectly valid use-case where we have an empty label terminating a fully qualified domain name.
  • Loading branch information
andrewstucki authored Aug 20, 2024
1 parent aca43d8 commit df79bbd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/kube/dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ func (p *PodDialer) parseDNS(fqdn string) (types.NamespacedName, int, error) {

fqdn = addressPort[0]

// Trim any empty labels as our Helm chart-based
// URLS use FQDNs ending with an empty label
fqdn = strings.TrimSuffix(fqdn, ".")

isServiceDNS := true

if strings.Count(fqdn, ".") < 2 {
Expand Down
2 changes: 2 additions & 0 deletions pkg/kube/dialer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ func TestDialer(t *testing.T) {
// https pod-based DNS
"https://name.default",
"https://name",
// trailing dots
"http://name.service.default.svc.cluster.local.",
} {
t.Run(host, func(t *testing.T) {
_, err = httpClient.Get(host)
Expand Down

0 comments on commit df79bbd

Please sign in to comment.