Check Annotations map against nil for ConfigMapLock#Update()

Signed-off-by: Ted Yu <yuzhihong@gmail.com>

Kubernetes-commit: 086d6ae9bbbe95e0740e7dd44fa08c31409f8bec
This commit is contained in:
Ted Yu 2020-04-03 16:47:19 -07:00 committed by Kubernetes Publisher
parent 7039b495eb
commit 1ff0856e81

View File

@ -88,6 +88,9 @@ func (cml *ConfigMapLock) Update(ctx context.Context, ler LeaderElectionRecord)
if err != nil {
return err
}
if cml.cm.Annotations == nil {
cml.cm.Annotations = make(map[string]string)
}
cml.cm.Annotations[LeaderElectionRecordAnnotationKey] = string(recordBytes)
cml.cm, err = cml.Client.ConfigMaps(cml.ConfigMapMeta.Namespace).Update(ctx, cml.cm, metav1.UpdateOptions{})
return err