Prevent panic due to Annotations being nil map

This commit is contained in:
Ted Yu 2019-11-04 10:04:31 -08:00
parent 6a19261e96
commit c5792784e1

View File

@ -82,6 +82,9 @@ func (el *EndpointsLock) Update(ler LeaderElectionRecord) error {
if err != nil {
return err
}
if el.e.Annotations == nil {
el.e.Annotations = make(map[string]string)
}
el.e.Annotations[LeaderElectionRecordAnnotationKey] = string(recordBytes)
el.e, err = el.Client.Endpoints(el.EndpointsMeta.Namespace).Update(el.e)
return err