mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 06:27:05 +00:00
Merge pull request #90576 from gaurav1086/azure_optimize_locks
[Provider/Azure] optimize mutex locks
This commit is contained in:
commit
ec36ff4001
@ -253,7 +253,7 @@ type Cloud struct {
|
|||||||
// ipv6DualStack allows overriding for unit testing. It's normally initialized from featuregates
|
// ipv6DualStack allows overriding for unit testing. It's normally initialized from featuregates
|
||||||
ipv6DualStackEnabled bool
|
ipv6DualStackEnabled bool
|
||||||
// Lock for access to node caches, includes nodeZones, nodeResourceGroups, and unmanagedNodes.
|
// Lock for access to node caches, includes nodeZones, nodeResourceGroups, and unmanagedNodes.
|
||||||
nodeCachesLock sync.Mutex
|
nodeCachesLock sync.RWMutex
|
||||||
// nodeZones is a mapping from Zone to a sets.String of Node's names in the Zone
|
// nodeZones is a mapping from Zone to a sets.String of Node's names in the Zone
|
||||||
// it is updated by the nodeInformer
|
// it is updated by the nodeInformer
|
||||||
nodeZones map[string]sets.String
|
nodeZones map[string]sets.String
|
||||||
@ -812,8 +812,8 @@ func (az *Cloud) GetActiveZones() (sets.String, error) {
|
|||||||
return nil, fmt.Errorf("Azure cloud provider doesn't have informers set")
|
return nil, fmt.Errorf("Azure cloud provider doesn't have informers set")
|
||||||
}
|
}
|
||||||
|
|
||||||
az.nodeCachesLock.Lock()
|
az.nodeCachesLock.RLock()
|
||||||
defer az.nodeCachesLock.Unlock()
|
defer az.nodeCachesLock.RUnlock()
|
||||||
if !az.nodeInformerSynced() {
|
if !az.nodeInformerSynced() {
|
||||||
return nil, fmt.Errorf("node informer is not synced when trying to GetActiveZones")
|
return nil, fmt.Errorf("node informer is not synced when trying to GetActiveZones")
|
||||||
}
|
}
|
||||||
@ -839,8 +839,8 @@ func (az *Cloud) GetNodeResourceGroup(nodeName string) (string, error) {
|
|||||||
return az.ResourceGroup, nil
|
return az.ResourceGroup, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
az.nodeCachesLock.Lock()
|
az.nodeCachesLock.RLock()
|
||||||
defer az.nodeCachesLock.Unlock()
|
defer az.nodeCachesLock.RUnlock()
|
||||||
if !az.nodeInformerSynced() {
|
if !az.nodeInformerSynced() {
|
||||||
return "", fmt.Errorf("node informer is not synced when trying to GetNodeResourceGroup")
|
return "", fmt.Errorf("node informer is not synced when trying to GetNodeResourceGroup")
|
||||||
}
|
}
|
||||||
@ -861,8 +861,8 @@ func (az *Cloud) GetResourceGroups() (sets.String, error) {
|
|||||||
return sets.NewString(az.ResourceGroup), nil
|
return sets.NewString(az.ResourceGroup), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
az.nodeCachesLock.Lock()
|
az.nodeCachesLock.RLock()
|
||||||
defer az.nodeCachesLock.Unlock()
|
defer az.nodeCachesLock.RUnlock()
|
||||||
if !az.nodeInformerSynced() {
|
if !az.nodeInformerSynced() {
|
||||||
return nil, fmt.Errorf("node informer is not synced when trying to GetResourceGroups")
|
return nil, fmt.Errorf("node informer is not synced when trying to GetResourceGroups")
|
||||||
}
|
}
|
||||||
@ -882,8 +882,8 @@ func (az *Cloud) GetUnmanagedNodes() (sets.String, error) {
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
az.nodeCachesLock.Lock()
|
az.nodeCachesLock.RLock()
|
||||||
defer az.nodeCachesLock.Unlock()
|
defer az.nodeCachesLock.RUnlock()
|
||||||
if !az.nodeInformerSynced() {
|
if !az.nodeInformerSynced() {
|
||||||
return nil, fmt.Errorf("node informer is not synced when trying to GetUnmanagedNodes")
|
return nil, fmt.Errorf("node informer is not synced when trying to GetUnmanagedNodes")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user