Detect path collisions in Ingress rules
This commit is contained in:
parent
64791c35f0
commit
724a829eae
1 changed files with 14 additions and 9 deletions
|
@ -458,9 +458,9 @@ func (lbc *loadBalancerController) getUpstreamServers(data []interface{}) ([]*ng
|
||||||
}
|
}
|
||||||
|
|
||||||
server := servers[rule.Host]
|
server := servers[rule.Host]
|
||||||
locations := []*nginx.Location{}
|
|
||||||
|
|
||||||
for _, path := range rule.HTTP.Paths {
|
for _, path := range rule.HTTP.Paths {
|
||||||
|
|
||||||
upsName := fmt.Sprintf("%v-%v-%v", ing.GetNamespace(), path.Backend.ServiceName, path.Backend.ServicePort.IntValue())
|
upsName := fmt.Sprintf("%v-%v-%v", ing.GetNamespace(), path.Backend.ServiceName, path.Backend.ServicePort.IntValue())
|
||||||
ups := upstreams[upsName]
|
ups := upstreams[upsName]
|
||||||
|
|
||||||
|
@ -490,18 +490,23 @@ func (lbc *loadBalancerController) getUpstreamServers(data []interface{}) ([]*ng
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, ups := range upstreams {
|
// Validate that there is no another previuous rule
|
||||||
if upsName == ups.Name {
|
// for the same host and path.
|
||||||
loc := &nginx.Location{Path: path.Path}
|
skipLoc := false
|
||||||
loc.Upstream = *ups
|
for _, loc := range server.Locations {
|
||||||
locations = append(locations, loc)
|
if loc.Path == path.Path {
|
||||||
|
lbc.recorder.Eventf(ing, api.EventTypeWarning, "MAPPING", "Path '%v' already defined in another Ingress rule", path)
|
||||||
|
skipLoc = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
for _, loc := range locations {
|
if skipLoc == false {
|
||||||
server.Locations = append(server.Locations, loc)
|
server.Locations = append(server.Locations, &nginx.Location{
|
||||||
|
Path: path.Path,
|
||||||
|
Upstream: *ups,
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue