Merge pull request #78105 from cwdsuzhou/narrow_down_lock

Narrow down the lock
This commit is contained in:
Kubernetes Prow Robot 2019-06-14 04:08:23 -07:00 committed by GitHub
commit 5777fdfe31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 {
@ -306,6 +303,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)