diff --git a/pkg/controller/volume/attachdetach/cache/actual_state_of_world.go b/pkg/controller/volume/attachdetach/cache/actual_state_of_world.go index 249ac816874..4dc7fd3f402 100644 --- a/pkg/controller/volume/attachdetach/cache/actual_state_of_world.go +++ b/pkg/controller/volume/attachdetach/cache/actual_state_of_world.go @@ -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 { @@ -306,6 +303,9 @@ func (asw *actualStateOfWorld) AddVolumeNode( } } + asw.Lock() + defer asw.Unlock() + volumeObj, volumeExists := asw.attachedVolumes[volumeName] if !volumeExists { volumeObj = attachedVolume{ diff --git a/pkg/controller/volume/attachdetach/cache/desired_state_of_world.go b/pkg/controller/volume/attachdetach/cache/desired_state_of_world.go index 9ce39a83d07..32f60694f7b 100644 --- a/pkg/controller/volume/attachdetach/cache/desired_state_of_world.go +++ b/pkg/controller/volume/attachdetach/cache/desired_state_of_world.go @@ -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)