Properly set ing.Service when there are multiple rules with different hosts using the same path
Fixes #3611 Signed-off-by: Alejandro Pedraza <alejandro.pedraza@gmail.com>
This commit is contained in:
parent
ef0b1633e2
commit
a3c87cf9cb
2 changed files with 12 additions and 2 deletions
|
@ -731,13 +731,19 @@ func (info *ingressInformation) Equal(other *ingressInformation) bool {
|
|||
return true
|
||||
}
|
||||
|
||||
func getIngressInformation(i, p interface{}) *ingressInformation {
|
||||
func getIngressInformation(i, h, p interface{}) *ingressInformation {
|
||||
ing, ok := i.(*ingress.Ingress)
|
||||
if !ok {
|
||||
klog.Errorf("expected an '*ingress.Ingress' type but %T was returned", i)
|
||||
return &ingressInformation{}
|
||||
}
|
||||
|
||||
hostname, ok := h.(string)
|
||||
if !ok {
|
||||
klog.Errorf("expected a 'string' type but %T was returned", h)
|
||||
return &ingressInformation{}
|
||||
}
|
||||
|
||||
path, ok := p.(string)
|
||||
if !ok {
|
||||
klog.Errorf("expected a 'string' type but %T was returned", p)
|
||||
|
@ -763,6 +769,10 @@ func getIngressInformation(i, p interface{}) *ingressInformation {
|
|||
continue
|
||||
}
|
||||
|
||||
if hostname != "" && hostname != rule.Host {
|
||||
continue
|
||||
}
|
||||
|
||||
for _, rPath := range rule.HTTP.Paths {
|
||||
if path == rPath.Path {
|
||||
info.Service = rPath.Backend.ServiceName
|
||||
|
|
|
@ -1014,7 +1014,7 @@ stream {
|
|||
{{ end }}
|
||||
|
||||
location {{ $path }} {
|
||||
{{ $ing := (getIngressInformation $location.Ingress $location.Path) }}
|
||||
{{ $ing := (getIngressInformation $location.Ingress $server.Hostname $location.Path) }}
|
||||
set $namespace "{{ $ing.Namespace }}";
|
||||
set $ingress_name "{{ $ing.Rule }}";
|
||||
set $service_name "{{ $ing.Service }}";
|
||||
|
|
Loading…
Reference in a new issue