fix: Update unit test to catch actual nil Labels case and fix functionality to handle nil Labels

Kubernetes-commit: 8d4108bf9355b086e7f8996e84723ca389db887a
This commit is contained in:
DerekFrank
2025-08-15 14:28:18 -07:00
committed by Kubernetes Publisher
parent bccbbb3816
commit 706156ceaf
2 changed files with 27 additions and 17 deletions

View File

@@ -77,6 +77,9 @@ func (ll *LeaseLock) Update(ctx context.Context, ler LeaderElectionRecord) error
ll.lease.Spec = LeaderElectionRecordToLeaseSpec(&ler)
if ll.Labels != nil {
if ll.lease.Labels == nil {
ll.lease.Labels = map[string]string{}
}
// Only overwrite the labels that are specifically set
for k, v := range ll.Labels {
ll.lease.Labels[k] = v