Skip to content

Commit 4119a69

Browse files
committed
fix: hostname collision between different Tenant namespaces
1 parent 51de469 commit 4119a69

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

pkg/webhook/ingress/validating.go

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,9 @@ func (r *handler) validateCollision(ctx context.Context, clt client.Client, ingr
218218
return nil
219219
}
220220
for _, hostname := range ingress.Hostnames() {
221-
var err error
222221
collisionErr := NewIngressHostnameCollision(hostname)
223222

223+
var err error
224224
switch ingress.(type) {
225225
case Extension:
226226
el := &extensionsv1beta1.IngressList{}
@@ -231,11 +231,12 @@ func (r *handler) validateCollision(ctx context.Context, clt client.Client, ingr
231231
}
232232
switch len(el.Items) {
233233
case 0:
234-
continue
234+
break
235235
case 1:
236-
if el.Items[0].GetName() != ingress.Name() {
237-
return collisionErr
236+
if f := el.Items[0]; f.GetName() == ingress.Name() && f.GetNamespace() == ingress.Namespace() {
237+
break
238238
}
239+
fallthrough
239240
default:
240241
return collisionErr
241242
}
@@ -249,11 +250,12 @@ func (r *handler) validateCollision(ctx context.Context, clt client.Client, ingr
249250
}
250251
switch len(nl.Items) {
251252
case 0:
252-
continue
253+
break
253254
case 1:
254-
if nl.Items[0].GetName() != ingress.Name() {
255-
return collisionErr
255+
if f := nl.Items[0]; f.GetName() == ingress.Name() && f.GetNamespace() == ingress.Namespace() {
256+
break
256257
}
258+
fallthrough
257259
default:
258260
return collisionErr
259261
}
@@ -267,11 +269,12 @@ func (r *handler) validateCollision(ctx context.Context, clt client.Client, ingr
267269
}
268270
switch len(nlb.Items) {
269271
case 0:
270-
continue
272+
break
271273
case 1:
272-
if nlb.Items[0].GetName() != ingress.Name() {
273-
return collisionErr
274+
if f := nlb.Items[0]; f.GetName() == ingress.Name() && f.GetNamespace() == ingress.Namespace() {
275+
break
274276
}
277+
fallthrough
275278
default:
276279
return collisionErr
277280
}

0 commit comments

Comments
 (0)