Merge pull request #560 from jcmoraisjr/jm-fix-secure-shadow

Fix intermittent misconfiguration of backend.secure and SessionAffinity
This commit is contained in:
Manuel Alejandro de Brito Fontes 2017-04-05 23:03:04 -03:00 committed by GitHub
commit 847c05d205

View file

@ -807,30 +807,36 @@ func (ic *GenericController) createUpstreams(data []interface{}) map[string]*ing
path.Backend.ServiceName, path.Backend.ServiceName,
path.Backend.ServicePort.String()) path.Backend.ServicePort.String())
if _, ok := upstreams[name]; ok { upstream, ok := upstreams[name]
continue isNewUpstream := !ok
if isNewUpstream {
glog.V(3).Infof("creating upstream %v", name)
upstream = newUpstream(name)
upstreams[name] = upstream
} }
glog.V(3).Infof("creating upstream %v", name) if !upstream.Secure {
upstreams[name] = newUpstream(name) upstream.Secure = secUpstream
if !upstreams[name].Secure {
upstreams[name].Secure = secUpstream
} }
if upstreams[name].SessionAffinity.AffinityType == "" {
upstreams[name].SessionAffinity.AffinityType = affinity.AffinityType if upstream.SessionAffinity.AffinityType == "" {
upstream.SessionAffinity.AffinityType = affinity.AffinityType
if affinity.AffinityType == "cookie" { if affinity.AffinityType == "cookie" {
upstreams[name].SessionAffinity.CookieSessionAffinity.Name = affinity.CookieConfig.Name upstream.SessionAffinity.CookieSessionAffinity.Name = affinity.CookieConfig.Name
upstreams[name].SessionAffinity.CookieSessionAffinity.Hash = affinity.CookieConfig.Hash upstream.SessionAffinity.CookieSessionAffinity.Hash = affinity.CookieConfig.Hash
} }
} }
svcKey := fmt.Sprintf("%v/%v", ing.GetNamespace(), path.Backend.ServiceName) if isNewUpstream {
endp, err := ic.serviceEndpoints(svcKey, path.Backend.ServicePort.String(), hz) svcKey := fmt.Sprintf("%v/%v", ing.GetNamespace(), path.Backend.ServiceName)
if err != nil { endp, err := ic.serviceEndpoints(svcKey, path.Backend.ServicePort.String(), hz)
glog.Warningf("error obtaining service endpoints: %v", err) if err != nil {
continue glog.Warningf("error obtaining service endpoints: %v", err)
continue
}
upstream.Endpoints = endp
} }
upstreams[name].Endpoints = endp
} }
} }
} }