Commit 4f8b60b4 authored by Geoff Simmons's avatar Geoff Simmons

Bugfix a potential nil dereference.

parent d0f2f5c3
......@@ -709,6 +709,16 @@ func (hc *Controller) getOffldStatus(inst *haproxyInst) error {
return nil
}
func mkSvc(addrs []OffldAddr) *offldrSvc {
svc := &offldrSvc{instances: make([]*haproxyInst, len(addrs))}
for i, addr := range addrs {
instance := offldAddr2haproxyInst(addr, nil)
svc.instances[i] = instance
// instsGauge.Inc()
}
return svc
}
// AddOrUpdateOffloader sets the configuration for the offloader
// designated by key, using the given addresses for remote admin, and
// the Secret designated by secrName as the password for Basic Auth in
......@@ -722,16 +732,7 @@ func (hc *Controller) AddOrUpdateOffloader(
var passwdPtr *string
svc, exists := hc.svcs[key]
if !exists {
var instances []*haproxyInst
svc = &offldrSvc{}
for _, addr := range addrs {
instance := offldAddr2haproxyInst(addr, nil)
hc.log.Debugf("offloader svc %s: creating instance %+v",
key, *instance)
instances = append(instances, instance)
// instsGauge.Inc()
}
svc.instances = instances
svc = mkSvc(addrs)
hc.svcs[key] = svc
// svcsGauge.Inc()
hc.log.Debugf("offloader svc %s: created config", key)
......@@ -777,7 +778,7 @@ func (hc *Controller) Update(
) update.Status {
svc, exists := hc.svcs[svcKey]
if !exists {
svc = &offldrSvc{instances: make([]*haproxyInst, len(addrs))}
svc = mkSvc(addrs)
hc.svcs[svcKey] = svc
// svcsGauge.Inc()
hc.log.Infof("Added offloader service definition %s", svcKey)
......
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