Commit b1108640 authored by Geoff Simmons's avatar Geoff Simmons

Varnish controller updates service instance addresses when necessary.

That is, when the addresses are not stored in the controller's
internal data structures.
parent 9d4413d2
......@@ -654,6 +654,17 @@ func (vc *Controller) updateBeGauges() {
beEndpsGauge.Set(float64(nBeEndps))
}
func (vc *Controller) setInstAddrs(svc *varnishSvc, addrs []vcl.Address) {
for i, addr := range addrs {
svc.instances[i] = &varnishInst{
ns: addr.PodNamespace,
name: addr.PodName,
addr: addr.Address(),
admMtx: &sync.Mutex{},
}
}
}
// Update a Varnish Service to implement an configuration.
//
// svcKey: namespace/name key for the Service
......@@ -680,21 +691,17 @@ func (vc *Controller) Update(
}
}
svc, exists := vc.svcs[svcKey]
if !exists {
if !exists || svc == nil {
svc = &varnishSvc{
instances: make([]*varnishInst, len(addrs)),
}
for i, addr := range addrs {
svc.instances[i] = &varnishInst{
ns: addr.PodNamespace,
name: addr.PodName,
addr: addr.Address(),
admMtx: &sync.Mutex{},
}
}
vc.setInstAddrs(svc, addrs)
vc.svcs[svcKey] = svc
svcsGauge.Inc()
vc.log.Infof("Added Varnish service definition %s", svcKey)
} else if len(svc.instances) == 0 {
svc.instances = make([]*varnishInst, len(addrs))
vc.setInstAddrs(svc, addrs)
}
svc.cfgLoaded = false
if svc.spec == nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment