Skip to content

Commit

Permalink
fix: hostname collision between different Tenant namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
prometherion committed Mar 6, 2021
1 parent 51de469 commit 4119a69
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions pkg/webhook/ingress/validating.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,9 @@ func (r *handler) validateCollision(ctx context.Context, clt client.Client, ingr
return nil
}
for _, hostname := range ingress.Hostnames() {
var err error
collisionErr := NewIngressHostnameCollision(hostname)

var err error
switch ingress.(type) {
case Extension:
el := &extensionsv1beta1.IngressList{}
Expand All @@ -231,11 +231,12 @@ func (r *handler) validateCollision(ctx context.Context, clt client.Client, ingr
}
switch len(el.Items) {
case 0:
continue
break
case 1:
if el.Items[0].GetName() != ingress.Name() {
return collisionErr
if f := el.Items[0]; f.GetName() == ingress.Name() && f.GetNamespace() == ingress.Namespace() {
break
}
fallthrough
default:
return collisionErr
}
Expand All @@ -249,11 +250,12 @@ func (r *handler) validateCollision(ctx context.Context, clt client.Client, ingr
}
switch len(nl.Items) {
case 0:
continue
break
case 1:
if nl.Items[0].GetName() != ingress.Name() {
return collisionErr
if f := nl.Items[0]; f.GetName() == ingress.Name() && f.GetNamespace() == ingress.Namespace() {
break
}
fallthrough
default:
return collisionErr
}
Expand All @@ -267,11 +269,12 @@ func (r *handler) validateCollision(ctx context.Context, clt client.Client, ingr
}
switch len(nlb.Items) {
case 0:
continue
break
case 1:
if nlb.Items[0].GetName() != ingress.Name() {
return collisionErr
if f := nlb.Items[0]; f.GetName() == ingress.Name() && f.GetNamespace() == ingress.Namespace() {
break
}
fallthrough
default:
return collisionErr
}
Expand Down

0 comments on commit 4119a69

Please sign in to comment.