Narrow down the lock

This commit is contained in:
caiweidong
2019-05-20 19:12:27 +08:00
parent 81a61ae0e3
commit 5a0e7f19b6
2 changed files with 4 additions and 4 deletions

View File

@@ -277,9 +277,6 @@ func (asw *actualStateOfWorld) AddVolumeToReportAsAttached(
func (asw *actualStateOfWorld) AddVolumeNode(
uniqueName v1.UniqueVolumeName, volumeSpec *volume.Spec, nodeName types.NodeName, devicePath string, isAttached bool) (v1.UniqueVolumeName, error) {
asw.Lock()
defer asw.Unlock()
volumeName := uniqueName
if volumeName == "" {
if volumeSpec == nil {
@@ -303,6 +300,9 @@ func (asw *actualStateOfWorld) AddVolumeNode(
}
}
asw.Lock()
defer asw.Unlock()
volumeObj, volumeExists := asw.attachedVolumes[volumeName]
if !volumeExists {
volumeObj = attachedVolume{

View File

@@ -102,7 +102,7 @@ type DesiredStateOfWorld interface {
// mounted and attached for terminated pods
GetKeepTerminatedPodVolumesForNode(k8stypes.NodeName) bool
// Mark multiattach error as reported to prevent spamming multiple
// Mark multi-attach error as reported to prevent spamming multiple
// events for same error
SetMultiAttachError(v1.UniqueVolumeName, k8stypes.NodeName)