Skip to content

Commit

Permalink
OCPBUGS-4759: Do not manage DNS for an ingresscontroller with a domai…
Browse files Browse the repository at this point in the history
…n that does not match

the baseDomain of the cluster DNS config for GCP

This had been previously done for AWS, now expanding to GCP.

- pkg/operator/controller/ingress/dns.go: Add GCP domain validation to manageDNSForDomain
- pkg/operator/controller/ingress/dns_test.go: Add unit tests for manageDNSForDomain with GCP
  • Loading branch information
gcs278 committed Jan 11, 2023
1 parent d9d1a2b commit cb8d9bb
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
4 changes: 2 additions & 2 deletions pkg/operator/controller/ingress/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func dnsRecordChanged(current, expected *iov1.DNSRecord) (bool, *iov1.DNSRecord)
}

// manageDNSForDomain returns true if the given domain contains the baseDomain
// of the cluster DNS config. It is only used for AWS in the beginning, and will be expanded to other clouds
// of the cluster DNS config. It is only used for AWS and GCP in the beginning, and will be expanded to other clouds
// once we know there are no users depending on this.
// See https://bugzilla.redhat.com/show_bug.cgi?id=2041616
func manageDNSForDomain(domain string, status *configv1.PlatformStatus, dnsConfig *configv1.DNS) bool {
Expand All @@ -210,7 +210,7 @@ func manageDNSForDomain(domain string, status *configv1.PlatformStatus, dnsConfi

mustContain := "." + dnsConfig.Spec.BaseDomain
switch status.Type {
case configv1.AWSPlatformType:
case configv1.AWSPlatformType, configv1.GCPPlatformType:
return strings.HasSuffix(domain, mustContain)
default:
return true
Expand Down
27 changes: 24 additions & 3 deletions pkg/operator/controller/ingress/dns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,14 @@ func TestManageDNSForDomain(t *testing.T) {
expected: false,
},
{
name: "domain matches the baseDomain",
name: "domain matches the baseDomain on AWS",
domain: "apps.openshift.example.com",
baseDomain: "openshift.example.com",
platformType: configv1.AWSPlatformType,
expected: true,
},
{
name: "domain matches single segment baseDomain",
name: "domain matches single segment baseDomain on AWS",
domain: "openshift.example.com",
baseDomain: "example.com",
platformType: configv1.AWSPlatformType,
Expand All @@ -189,12 +189,33 @@ func TestManageDNSForDomain(t *testing.T) {
expected: false,
},
{
name: "domain does not match prematurely",
name: "domain does not match prematurely on AWS",
domain: "testopenshift.example.com",
baseDomain: "openshift.example.com",
platformType: configv1.AWSPlatformType,
expected: false,
},
{
name: "domain matches the baseDomain on GCP",
domain: "apps.openshift.example.com",
baseDomain: "openshift.example.com",
platformType: configv1.GCPPlatformType,
expected: true,
},
{
name: "domain does not match the baseDomain on GCP",
domain: "test.local",
baseDomain: "openshift.example.com",
platformType: configv1.GCPPlatformType,
expected: false,
},
{
name: "domain does not match prematurely on GCP",
domain: "testopenshift.example.com",
baseDomain: "openshift.example.com",
platformType: configv1.GCPPlatformType,
expected: false,
},
{
name: "domain does not match the baseDomain on unsupported platform",
domain: "test.local",
Expand Down

0 comments on commit cb8d9bb

Please sign in to comment.