diff --git a/pkg/kubelet/volumemanager/cache/actual_state_of_world.go b/pkg/kubelet/volumemanager/cache/actual_state_of_world.go index 182657e1c11..e68b3380480 100644 --- a/pkg/kubelet/volumemanager/cache/actual_state_of_world.go +++ b/pkg/kubelet/volumemanager/cache/actual_state_of_world.go @@ -127,7 +127,7 @@ type ActualStateOfWorld interface { // actual state of the world. 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. GetAllMountedVolumes() []MountedVolume @@ -635,6 +635,10 @@ func (asw *actualStateOfWorld) PodExistsInVolume( podObj, podExists := volumeObj.mountedPods[podName] 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 { return true, volumeObj.devicePath, newRemountRequiredError(volumeObj.volumeName, podObj.podName) } diff --git a/pkg/kubelet/volumemanager/cache/actual_state_of_world_test.go b/pkg/kubelet/volumemanager/cache/actual_state_of_world_test.go index 88ae2e283e8..684c02afe0d 100644 --- a/pkg/kubelet/volumemanager/cache/actual_state_of_world_test.go +++ b/pkg/kubelet/volumemanager/cache/actual_state_of_world_test.go @@ -592,7 +592,7 @@ func Test_MarkDeviceAsMounted_Positive_NewVolume(t *testing.T) { verifyVolumeExistsInGloballyMountedVolumes(t, generatedVolumeName, asw) } -func TestGetMountedVolumesForPod(t *testing.T) { +func TestUncertainVolumeMounts(t *testing.T) { // Arrange volumePluginMgr, plugin := volumetesting.GetTestVolumePluginMgr(t) asw := NewActualStateOfWorld("mynode" /* nodeName */, volumePluginMgr) @@ -655,6 +655,11 @@ func TestGetMountedVolumesForPod(t *testing.T) { if volumeFound { 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( diff --git a/pkg/volume/csi/csi_client.go b/pkg/volume/csi/csi_client.go index 6f54f871e8f..aa00d85e859 100644 --- a/pkg/volume/csi/csi_client.go +++ b/pkg/volume/csi/csi_client.go @@ -639,7 +639,7 @@ func isFinalError(err error) bool { case codes.Canceled, // gRPC: Client Application cancelled the request codes.DeadlineExceeded, // gRPC: Timeout 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 return false }