Remove any aliases that conflict with a hostname

Removes the alias association if an existing server
with the same hostname as the alias exists. This is
done to disallow any duplicate server creation when
the alias annotation is provided.
This commit is contained in:
Fernando Diaz 2017-08-17 12:05:01 -05:00
parent 62fea9aa01
commit e12138f4dc
4 changed files with 19 additions and 9 deletions

View file

@ -605,6 +605,16 @@ func (ic *GenericController) getBackendServers() ([]*ingress.Backend, []*ingress
upstreams := ic.createUpstreams(ings)
servers := ic.createServers(ings, upstreams)
// If a server has a hostname equivalent to a pre-existing alias, then we remove the alias
for _, server := range servers {
for j, alias := range servers {
if server.Hostname == alias.Alias {
glog.Warningf("There is a conflict with hostname '%v' and alias of `%v`.", server.Hostname, alias.Hostname)
servers[j].Alias = ""
}
}
}
for _, ingIf := range ings {
ing := ingIf.(*extensions.Ingress)