Prevent panic due to Annotations being nil map

Kubernetes-commit: c5792784e1ae689cb4c949b9c556ee1e4896064a
This commit is contained in:
Ted Yu 2019-11-04 10:04:31 -08:00 committed by Kubernetes Publisher
parent d063930b33
commit 93a8bb4af0

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