Merge pull request #76712 from tedyu/rr-read-lock

Use read lock for ServiceHasEndpoints
k3s-v1.15.3
Kubernetes Prow Robot 2019-05-01 23:28:31 -07:00 committed by GitHub
commit a949abc5bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -122,8 +122,8 @@ func isSessionAffinity(affinity *affinityPolicy) bool {
// ServiceHasEndpoints checks whether a service entry has endpoints.
func (lb *LoadBalancerRR) ServiceHasEndpoints(svcPort proxy.ServicePortName) bool {
lb.lock.Lock()
defer lb.lock.Unlock()
lb.lock.RLock()
defer lb.lock.RUnlock()
state, exists := lb.services[svcPort]
// TODO: while nothing ever assigns nil to the map, *some* of the code using the map
// checks for it. The code should all follow the same convention.