Fix condition in server-alias annotation
This commit is contained in:
parent
4fdf9c98bf
commit
1216ed03f7
2 changed files with 29 additions and 1 deletions
|
@ -1066,7 +1066,7 @@ func (n *NGINXController) createServers(data []*ingress.Ingress,
|
|||
|
||||
if len(servers[host].Aliases) == 0 {
|
||||
servers[host].Aliases = anns.Aliases
|
||||
if _, ok := allAliases[host]; !ok {
|
||||
if aliases := allAliases[host]; len(aliases) == 0 {
|
||||
allAliases[host] = anns.Aliases
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -83,4 +83,32 @@ var _ = framework.DescribeAnnotation("server-alias", func() {
|
|||
Body().Contains(fmt.Sprintf("host=%v", host))
|
||||
}
|
||||
})
|
||||
|
||||
ginkgo.It("should return status code 200 for hosts defined in two ingresses, different path with one alias", func() {
|
||||
host := "foo"
|
||||
|
||||
ing := framework.NewSingleIngress("app-a", "/app-a", host, f.Namespace, framework.EchoService, 80, nil)
|
||||
f.EnsureIngress(ing)
|
||||
|
||||
annotations := map[string]string{
|
||||
"nginx.ingress.kubernetes.io/server-alias": "bar",
|
||||
}
|
||||
ing = framework.NewSingleIngress("app-b", "/app-b", host, f.Namespace, framework.EchoService, 80, annotations)
|
||||
f.EnsureIngress(ing)
|
||||
|
||||
f.WaitForNginxServer(host,
|
||||
func(server string) bool {
|
||||
return strings.Contains(server, fmt.Sprintf("server_name %v bar", host))
|
||||
})
|
||||
|
||||
hosts := []string{"foo", "bar"}
|
||||
for _, host := range hosts {
|
||||
f.HTTPTestClient().
|
||||
GET("/app-a").
|
||||
WithHeader("Host", host).
|
||||
Expect().
|
||||
Status(http.StatusOK).
|
||||
Body().Contains(fmt.Sprintf("host=%v", host))
|
||||
}
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue