Skip to content

Commit

Permalink
Do a case insensitive match when checking for duplicate FQDNs (projec…
Browse files Browse the repository at this point in the history
…tcontour#3231)

Do a case insensitive match when checking for duplicate FQDNs to avoid RouteConfiguration failures.

Fixes projectcontour#3230.

Signed-off-by: Keith Burdis <keith.burdis@gs.com>
  • Loading branch information
erwbgy committed Jan 14, 2021
1 parent 8a58d6d commit 2b52c1f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
3 changes: 2 additions & 1 deletion internal/dag/httpproxy_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,8 @@ func (p *HTTPProxyProcessor) validHTTPProxies() []*contour_api_v1.HTTPProxy {
valid = append(valid, proxy)
continue
}
fqdnHTTPProxies[proxy.Spec.VirtualHost.Fqdn] = append(fqdnHTTPProxies[proxy.Spec.VirtualHost.Fqdn], proxy)
fqdn := strings.ToLower(proxy.Spec.VirtualHost.Fqdn)
fqdnHTTPProxies[fqdn] = append(fqdnHTTPProxies[fqdn], proxy)
}

for fqdn, proxies := range fqdnHTTPProxies {
Expand Down
30 changes: 30 additions & 0 deletions internal/dag/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,24 @@ func TestDAGStatus(t *testing.T) {
},
}

proxyValidReuseCaseExampleCom := &contour_api_v1.HTTPProxy{
ObjectMeta: metav1.ObjectMeta{
Name: "case-example",
Namespace: "roots",
},
Spec: contour_api_v1.HTTPProxySpec{
VirtualHost: &contour_api_v1.VirtualHost{
Fqdn: "EXAMPLE.com",
},
Routes: []contour_api_v1.Route{{
Services: []contour_api_v1.Service{{
Name: "kuard",
Port: 8080,
}},
}},
},
}

run(t, "conflicting proxies due to fqdn reuse", testcase{
objs: []interface{}{proxyValidExampleCom, proxyValidReuseExampleCom},
want: map[types.NamespacedName]contour_api_v1.DetailedCondition{
Expand All @@ -822,6 +840,18 @@ func TestDAGStatus(t *testing.T) {
},
})

run(t, "conflicting proxies due to fqdn reuse with uppercase/lowercase", testcase{
objs: []interface{}{proxyValidExampleCom, proxyValidReuseCaseExampleCom},
want: map[types.NamespacedName]contour_api_v1.DetailedCondition{
{Name: proxyValidExampleCom.Name, Namespace: proxyValidExampleCom.Namespace}: fixture.NewValidCondition().
WithGeneration(proxyValidExampleCom.Generation).
WithError(contour_api_v1.ConditionTypeVirtualHostError, "DuplicateVhost", `fqdn "example.com" is used in multiple HTTPProxies: roots/case-example, roots/example-com`),
{Name: proxyValidReuseCaseExampleCom.Name, Namespace: proxyValidReuseCaseExampleCom.Namespace}: fixture.NewValidCondition().
WithGeneration(proxyValidReuseCaseExampleCom.Generation).
WithError(contour_api_v1.ConditionTypeVirtualHostError, "DuplicateVhost", `fqdn "example.com" is used in multiple HTTPProxies: roots/case-example, roots/example-com`),
},
})

proxyRootIncludesRoot := &contour_api_v1.HTTPProxy{
ObjectMeta: metav1.ObjectMeta{
Name: "root-blog",
Expand Down

0 comments on commit 2b52c1f

Please sign in to comment.