-
Notifications
You must be signed in to change notification settings - Fork 181
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
OCPBUGS-15100: Create valid DNS names for Gateway API on GCP #949
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ package gateway_service_dns | |
import ( | ||
"context" | ||
"reflect" | ||
"strings" | ||
|
||
logf "github.com/openshift/cluster-ingress-operator/pkg/log" | ||
operatorcontroller "github.com/openshift/cluster-ingress-operator/pkg/operator/controller" | ||
|
@@ -222,6 +223,10 @@ func (r *reconciler) ensureDNSRecordsForGateway(ctx context.Context, gateway *ga | |
var errs []error | ||
for _, domain := range domains { | ||
name := operatorcontroller.GatewayDNSRecordName(gateway, domain) | ||
// If domain doesn't have a trailing dot, add it | ||
if !strings.HasSuffix(domain, ".") { | ||
domain = domain + "." | ||
} | ||
Comment on lines
+226
to
+229
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You need to account for the trailing dot in diff --git a/pkg/operator/controller/gateway-service-dns/controller.go b/pkg/operator/controller/gateway-service-dns/controller.go
index 1084d65c..919b8d32 100644
--- a/pkg/operator/controller/gateway-service-dns/controller.go
+++ b/pkg/operator/controller/gateway-service-dns/controller.go
@@ -199,7 +199,12 @@ func getGatewayHostnames(gateway *gatewayapiv1beta1.Gateway) sets.String {
if listener.Hostname == nil || len(*listener.Hostname) == 0 {
continue
}
- domains.Insert(string(*listener.Hostname))
+ domain := string(*listener.Hostname)
+ // If domain doesn't have a trailing dot, add it.
+ if !strings.HasSuffix(domain, ".") {
+ domain = domain + "."
+ }
+ domains.Insert(domain)
}
return domains
}
@@ -223,10 +228,6 @@ func (r *reconciler) ensureDNSRecordsForGateway(ctx context.Context, gateway *ga
var errs []error
for _, domain := range domains {
name := operatorcontroller.GatewayDNSRecordName(gateway, domain)
- // If domain doesn't have a trailing dot, add it
- if !strings.HasSuffix(domain, ".") {
- domain = domain + "."
- }
_, _, err := dnsrecord.EnsureDNSRecord(r.client, name, labels, ownerRef, domain, service)
errs = append(errs, err)
} This also has the advantage that "foo.com" without a trailing "." and and "foo.com." with a trailing "." will get the same hash. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in #956 |
||
_, _, err := dnsrecord.EnsureDNSRecord(r.client, name, labels, ownerRef, domain, service) | ||
errs = append(errs, err) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have added the trailing dot in
desiredDNSRecord
, but maybe this makes more sense.