Fix label mutation in endpoints controller

This commit is contained in:
Jordan Liggitt
2019-11-15 15:30:42 -05:00
parent 452c8c9ad3
commit 08b5c809d2
3 changed files with 16 additions and 5 deletions

View File

@@ -48,6 +48,7 @@ import (
"k8s.io/kubernetes/pkg/controller"
endpointutil "k8s.io/kubernetes/pkg/controller/util/endpoint"
"k8s.io/kubernetes/pkg/features"
utillabels "k8s.io/kubernetes/pkg/util/labels"
utilnet "k8s.io/utils/net"
)
@@ -503,9 +504,9 @@ func (e *EndpointController) syncService(key string) error {
}
if !helper.IsServiceIPSet(service) {
newEndpoints.Labels[v1.IsHeadlessService] = ""
newEndpoints.Labels = utillabels.CloneAndAddLabel(newEndpoints.Labels, v1.IsHeadlessService, "")
} else {
delete(newEndpoints.Labels, v1.IsHeadlessService)
newEndpoints.Labels = utillabels.CloneAndRemoveLabel(newEndpoints.Labels, v1.IsHeadlessService)
}
klog.V(4).Infof("Update endpoints for %v/%v, ready: %d not ready: %d", service.Namespace, service.Name, totalReadyEps, totalNotReadyEps)