etcd: Verify struct is not nil before accessing retries value

This didn't happen often because there's a nominateCallback race, but is
a bug which happened occasionally.
This commit is contained in:
James Shubin
2016-10-07 14:33:21 -04:00
parent 8ca5e38121
commit c2911bb2b7

View File

@@ -1409,8 +1409,12 @@ func (obj *EmbdEtcd) nominateCallback(re *RE) error {
obj.nominated, // other peer members and urls or empty map
)
if err != nil {
retries := 0
if re != nil {
retries = re.retries
}
// retry maxStartServerRetries times, then permanently fail
return &CtxRetriesErr{maxStartServerRetries - re.retries, fmt.Sprintf("Etcd: StartServer: Error: %+v", err)}
return &CtxRetriesErr{maxStartServerRetries - retries, fmt.Sprintf("Etcd: StartServer: Error: %+v", err)}
}
if len(obj.endpoints) == 0 {