@@ -253,7 +253,7 @@ type Cloud struct {
253
253
// ipv6DualStack allows overriding for unit testing. It's normally initialized from featuregates
254
254
ipv6DualStackEnabled bool
255
255
// Lock for access to node caches, includes nodeZones, nodeResourceGroups, and unmanagedNodes.
256
- nodeCachesLock sync.Mutex
256
+ nodeCachesLock sync.RWMutex
257
257
// nodeZones is a mapping from Zone to a sets.String of Node's names in the Zone
258
258
// it is updated by the nodeInformer
259
259
nodeZones map [string ]sets.String
@@ -812,8 +812,8 @@ func (az *Cloud) GetActiveZones() (sets.String, error) {
812
812
return nil , fmt .Errorf ("Azure cloud provider doesn't have informers set" )
813
813
}
814
814
815
- az .nodeCachesLock .Lock ()
816
- defer az .nodeCachesLock .Unlock ()
815
+ az .nodeCachesLock .RLock ()
816
+ defer az .nodeCachesLock .RUnlock ()
817
817
if ! az .nodeInformerSynced () {
818
818
return nil , fmt .Errorf ("node informer is not synced when trying to GetActiveZones" )
819
819
}
@@ -839,8 +839,8 @@ func (az *Cloud) GetNodeResourceGroup(nodeName string) (string, error) {
839
839
return az .ResourceGroup , nil
840
840
}
841
841
842
- az .nodeCachesLock .Lock ()
843
- defer az .nodeCachesLock .Unlock ()
842
+ az .nodeCachesLock .RLock ()
843
+ defer az .nodeCachesLock .RUnlock ()
844
844
if ! az .nodeInformerSynced () {
845
845
return "" , fmt .Errorf ("node informer is not synced when trying to GetNodeResourceGroup" )
846
846
}
@@ -861,8 +861,8 @@ func (az *Cloud) GetResourceGroups() (sets.String, error) {
861
861
return sets .NewString (az .ResourceGroup ), nil
862
862
}
863
863
864
- az .nodeCachesLock .Lock ()
865
- defer az .nodeCachesLock .Unlock ()
864
+ az .nodeCachesLock .RLock ()
865
+ defer az .nodeCachesLock .RUnlock ()
866
866
if ! az .nodeInformerSynced () {
867
867
return nil , fmt .Errorf ("node informer is not synced when trying to GetResourceGroups" )
868
868
}
@@ -882,8 +882,8 @@ func (az *Cloud) GetUnmanagedNodes() (sets.String, error) {
882
882
return nil , nil
883
883
}
884
884
885
- az .nodeCachesLock .Lock ()
886
- defer az .nodeCachesLock .Unlock ()
885
+ az .nodeCachesLock .RLock ()
886
+ defer az .nodeCachesLock .RUnlock ()
887
887
if ! az .nodeInformerSynced () {
888
888
return nil , fmt .Errorf ("node informer is not synced when trying to GetUnmanagedNodes" )
889
889
}
0 commit comments