Remove needless checks for nodestage during expansion

This commit is contained in:
Hemant Kumar 2022-03-10 09:55:06 -05:00
parent e24219d27b
commit 7fe33bfb7c
4 changed files with 1 additions and 32 deletions

View File

@ -32,7 +32,6 @@ func TestNodeExpand(t *testing.T) {
name string
nodeExpansion bool
nodeStageSet bool
volumePhase volume.CSIVolumePhaseType
success bool
fsVolume bool
grpcError error
@ -47,37 +46,26 @@ func TestNodeExpand(t *testing.T) {
name: "when nodeExpansion=on, nodeStage=on, volumePhase=staged",
nodeExpansion: true,
nodeStageSet: true,
volumePhase: volume.CSIVolumeStaged,
success: true,
fsVolume: true,
deviceStagePath: "/foo/bar",
},
{
name: "when nodeExpansion=on, nodeStage=off, volumePhase=staged",
nodeExpansion: true,
volumePhase: volume.CSIVolumeStaged,
success: false,
fsVolume: true,
},
{
name: "when nodeExpansion=on, nodeStage=on, volumePhase=published",
nodeExpansion: true,
nodeStageSet: true,
volumePhase: volume.CSIVolumePublished,
success: true,
fsVolume: true,
},
{
name: "when nodeExpansion=on, nodeStage=off, volumePhase=published",
nodeExpansion: true,
volumePhase: volume.CSIVolumePublished,
success: true,
fsVolume: true,
},
{
name: "when nodeExpansion=on, nodeStage=off, volumePhase=published, fsVolume=false",
nodeExpansion: true,
volumePhase: volume.CSIVolumePublished,
success: true,
fsVolume: false,
},
@ -85,7 +73,6 @@ func TestNodeExpand(t *testing.T) {
name: "when nodeExpansion=on, nodeStage=on, volumePhase=published has grpc volume-in-use error",
nodeExpansion: true,
nodeStageSet: true,
volumePhase: volume.CSIVolumePublished,
success: false,
fsVolume: true,
grpcError: status.Error(codes.FailedPrecondition, "volume-in-use"),
@ -95,7 +82,6 @@ func TestNodeExpand(t *testing.T) {
name: "when nodeExpansion=on, nodeStage=on, volumePhase=published has other grpc error",
nodeExpansion: true,
nodeStageSet: true,
volumePhase: volume.CSIVolumePublished,
success: false,
fsVolume: true,
grpcError: status.Error(codes.InvalidArgument, "invalid-argument"),
@ -117,7 +103,6 @@ func TestNodeExpand(t *testing.T) {
DeviceMountPath: "/foo/bar",
DeviceStagePath: "/foo/bar",
DevicePath: "/mnt/foobar",
CSIVolumePhase: tc.volumePhase,
}
csiSource, _ := getCSISourceFromSpec(resizeOptions.VolumeSpec)
csClient := setupClientWithExpansion(t, tc.nodeStageSet, tc.nodeExpansion)

View File

@ -53,9 +53,6 @@ type ProbeEvent struct {
Op ProbeOperation // The operation to the plugin
}
// CSIVolumePhaseType stores information about CSI volume path.
type CSIVolumePhaseType string
const (
// Common parameter which can be specified in StorageClass to specify the desired FSType
// Provisioners SHOULD implement support for this if they are block device based
@ -65,8 +62,6 @@ const (
ProbeAddOrUpdate ProbeOperation = 1 << iota
ProbeRemove
CSIVolumeStaged CSIVolumePhaseType = "staged"
CSIVolumePublished CSIVolumePhaseType = "published"
)
var (
@ -124,9 +119,6 @@ type NodeResizeOptions struct {
NewSize resource.Quantity
OldSize resource.Quantity
// CSIVolumePhase contains volume phase on the node
CSIVolumePhase CSIVolumePhaseType
}
type DynamicPluginProber interface {

View File

@ -478,12 +478,7 @@ func (plugin *FakeVolumePlugin) NodeExpand(resizeOptions NodeResizeOptions) (boo
return false, fmt.Errorf("Test failure: NodeExpand")
}
// Set up fakeVolumePlugin not support STAGE_UNSTAGE for testing the behavior
// so as volume can be node published before we can resize
if resizeOptions.CSIVolumePhase == volume.CSIVolumeStaged {
return false, nil
}
if resizeOptions.CSIVolumePhase == volume.CSIVolumePublished && resizeOptions.VolumeSpec.Name() == FailVolumeExpansion {
if resizeOptions.VolumeSpec.Name() == FailVolumeExpansion {
return false, fmt.Errorf("fail volume expansion for volume: %s", FailVolumeExpansion)
}
return true, nil

View File

@ -710,7 +710,6 @@ func (og *operationGenerator) GenerateMountVolumeFunc(
}
klog.V(verbosity).InfoS(detailedMsg, "pod", klog.KObj(volumeToMount.Pod))
resizeOptions.DeviceMountPath = volumeMounter.GetPath()
resizeOptions.CSIVolumePhase = volume.CSIVolumePublished
_, resizeError = og.nodeExpandVolume(volumeToMount, actualStateOfWorld, resizeOptions)
if resizeError != nil {
@ -1204,7 +1203,6 @@ func (og *operationGenerator) GenerateMapVolumeFunc(
resizeOptions := volume.NodeResizeOptions{
DevicePath: devicePath,
DeviceStagePath: stagingPath,
CSIVolumePhase: volume.CSIVolumePublished,
}
_, resizeError := og.nodeExpandVolume(volumeToMount, actualStateOfWorld, resizeOptions)
if resizeError != nil {
@ -1974,7 +1972,6 @@ func (og *operationGenerator) GenerateExpandInUseVolumeFunc(
}
// if we are doing online expansion then volume is already published
resizeOptions.CSIVolumePhase = volume.CSIVolumePublished
resizeDone, eventErr, detailedErr = og.doOnlineExpansion(volumeToMount, actualStateOfWorld, resizeOptions)
if eventErr != nil || detailedErr != nil {
return volumetypes.NewOperationContext(eventErr, detailedErr, migrated)