Commit 1be83c9d authored by Ted Yu's avatar Ted Yu Committed by Ted Yu

Utilize read lock for getLastObservedNodeAddresses

parent 78190f07
......@@ -901,7 +901,7 @@ type Kubelet struct {
iptClient utilipt.Interface
rootDirectory string
lastObservedNodeAddressesMux sync.Mutex
lastObservedNodeAddressesMux sync.RWMutex
lastObservedNodeAddresses []v1.NodeAddress
// onRepeatedHeartbeatFailure is called when a heartbeat operation fails more than once. optional.
......
......@@ -510,8 +510,8 @@ func (kl *Kubelet) setLastObservedNodeAddresses(addresses []v1.NodeAddress) {
kl.lastObservedNodeAddresses = addresses
}
func (kl *Kubelet) getLastObservedNodeAddresses() []v1.NodeAddress {
kl.lastObservedNodeAddressesMux.Lock()
defer kl.lastObservedNodeAddressesMux.Unlock()
kl.lastObservedNodeAddressesMux.RLock()
defer kl.lastObservedNodeAddressesMux.RUnlock()
return kl.lastObservedNodeAddresses
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment