Make sure PodExistsInVolume does not uses uncertain volumes

This commit is contained in:
Hemant Kumar 2019-09-10 11:58:13 -04:00
parent 34a6007dfe
commit 50dbcb3e00
3 changed files with 12 additions and 3 deletions

View File

@ -127,7 +127,7 @@ type ActualStateOfWorld interface {
// actual state of the world. // actual state of the world.
GetMountedVolumes() []MountedVolume GetMountedVolumes() []MountedVolume
// GetAllMountedVolumes returns list of all mounted volumes including // GetAllMountedVolumes returns list of all possibly mounted volumes including
// those that are in VolumeMounted state and VolumeMountUncertain state. // those that are in VolumeMounted state and VolumeMountUncertain state.
GetAllMountedVolumes() []MountedVolume GetAllMountedVolumes() []MountedVolume
@ -635,6 +635,10 @@ func (asw *actualStateOfWorld) PodExistsInVolume(
podObj, podExists := volumeObj.mountedPods[podName] podObj, podExists := volumeObj.mountedPods[podName]
if podExists { if podExists {
// if volume mount was uncertain we should keep trying to mount the volume
if podObj.volumeMountStateForPod == operationexecutor.VolumeMountUncertain {
return false, volumeObj.devicePath, nil
}
if podObj.remountRequired { if podObj.remountRequired {
return true, volumeObj.devicePath, newRemountRequiredError(volumeObj.volumeName, podObj.podName) return true, volumeObj.devicePath, newRemountRequiredError(volumeObj.volumeName, podObj.podName)
} }

View File

@ -592,7 +592,7 @@ func Test_MarkDeviceAsMounted_Positive_NewVolume(t *testing.T) {
verifyVolumeExistsInGloballyMountedVolumes(t, generatedVolumeName, asw) verifyVolumeExistsInGloballyMountedVolumes(t, generatedVolumeName, asw)
} }
func TestGetMountedVolumesForPod(t *testing.T) { func TestUncertainVolumeMounts(t *testing.T) {
// Arrange // Arrange
volumePluginMgr, plugin := volumetesting.GetTestVolumePluginMgr(t) volumePluginMgr, plugin := volumetesting.GetTestVolumePluginMgr(t)
asw := NewActualStateOfWorld("mynode" /* nodeName */, volumePluginMgr) asw := NewActualStateOfWorld("mynode" /* nodeName */, volumePluginMgr)
@ -655,6 +655,11 @@ func TestGetMountedVolumesForPod(t *testing.T) {
if volumeFound { if volumeFound {
t.Fatalf("expected volume %s to be not found in asw", volumeSpec1.Name()) t.Fatalf("expected volume %s to be not found in asw", volumeSpec1.Name())
} }
volExists, _, _ := asw.PodExistsInVolume(podName1, generatedVolumeName1)
if volExists {
t.Fatalf("expected volume %s to not exist in asw", generatedVolumeName1)
}
} }
func verifyVolumeExistsInGloballyMountedVolumes( func verifyVolumeExistsInGloballyMountedVolumes(

View File

@ -639,7 +639,7 @@ func isFinalError(err error) bool {
case codes.Canceled, // gRPC: Client Application cancelled the request case codes.Canceled, // gRPC: Client Application cancelled the request
codes.DeadlineExceeded, // gRPC: Timeout codes.DeadlineExceeded, // gRPC: Timeout
codes.Unavailable, // gRPC: Server shutting down, TCP connection broken - previous CreateVolume() may be still in progress. codes.Unavailable, // gRPC: Server shutting down, TCP connection broken - previous CreateVolume() may be still in progress.
codes.ResourceExhausted, // gRPC: Server temporarily out of resources - previous CreateVolume() may be still in progress. codes.ResourceExhausted, // gRPC: Server temporarily out of resources - previous Publish operation may be still in progress.
codes.Aborted: // CSI: Operation pending for volume codes.Aborted: // CSI: Operation pending for volume
return false return false
} }