Remove needless checks for nodestage during expansion
This commit is contained in:
parent
e24219d27b
commit
7fe33bfb7c
@ -32,7 +32,6 @@ func TestNodeExpand(t *testing.T) {
|
|||||||
name string
|
name string
|
||||||
nodeExpansion bool
|
nodeExpansion bool
|
||||||
nodeStageSet bool
|
nodeStageSet bool
|
||||||
volumePhase volume.CSIVolumePhaseType
|
|
||||||
success bool
|
success bool
|
||||||
fsVolume bool
|
fsVolume bool
|
||||||
grpcError error
|
grpcError error
|
||||||
@ -47,37 +46,26 @@ func TestNodeExpand(t *testing.T) {
|
|||||||
name: "when nodeExpansion=on, nodeStage=on, volumePhase=staged",
|
name: "when nodeExpansion=on, nodeStage=on, volumePhase=staged",
|
||||||
nodeExpansion: true,
|
nodeExpansion: true,
|
||||||
nodeStageSet: true,
|
nodeStageSet: true,
|
||||||
volumePhase: volume.CSIVolumeStaged,
|
|
||||||
success: true,
|
success: true,
|
||||||
fsVolume: true,
|
fsVolume: true,
|
||||||
deviceStagePath: "/foo/bar",
|
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",
|
name: "when nodeExpansion=on, nodeStage=on, volumePhase=published",
|
||||||
nodeExpansion: true,
|
nodeExpansion: true,
|
||||||
nodeStageSet: true,
|
nodeStageSet: true,
|
||||||
volumePhase: volume.CSIVolumePublished,
|
|
||||||
success: true,
|
success: true,
|
||||||
fsVolume: true,
|
fsVolume: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "when nodeExpansion=on, nodeStage=off, volumePhase=published",
|
name: "when nodeExpansion=on, nodeStage=off, volumePhase=published",
|
||||||
nodeExpansion: true,
|
nodeExpansion: true,
|
||||||
volumePhase: volume.CSIVolumePublished,
|
|
||||||
success: true,
|
success: true,
|
||||||
fsVolume: true,
|
fsVolume: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "when nodeExpansion=on, nodeStage=off, volumePhase=published, fsVolume=false",
|
name: "when nodeExpansion=on, nodeStage=off, volumePhase=published, fsVolume=false",
|
||||||
nodeExpansion: true,
|
nodeExpansion: true,
|
||||||
volumePhase: volume.CSIVolumePublished,
|
|
||||||
success: true,
|
success: true,
|
||||||
fsVolume: false,
|
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",
|
name: "when nodeExpansion=on, nodeStage=on, volumePhase=published has grpc volume-in-use error",
|
||||||
nodeExpansion: true,
|
nodeExpansion: true,
|
||||||
nodeStageSet: true,
|
nodeStageSet: true,
|
||||||
volumePhase: volume.CSIVolumePublished,
|
|
||||||
success: false,
|
success: false,
|
||||||
fsVolume: true,
|
fsVolume: true,
|
||||||
grpcError: status.Error(codes.FailedPrecondition, "volume-in-use"),
|
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",
|
name: "when nodeExpansion=on, nodeStage=on, volumePhase=published has other grpc error",
|
||||||
nodeExpansion: true,
|
nodeExpansion: true,
|
||||||
nodeStageSet: true,
|
nodeStageSet: true,
|
||||||
volumePhase: volume.CSIVolumePublished,
|
|
||||||
success: false,
|
success: false,
|
||||||
fsVolume: true,
|
fsVolume: true,
|
||||||
grpcError: status.Error(codes.InvalidArgument, "invalid-argument"),
|
grpcError: status.Error(codes.InvalidArgument, "invalid-argument"),
|
||||||
@ -117,7 +103,6 @@ func TestNodeExpand(t *testing.T) {
|
|||||||
DeviceMountPath: "/foo/bar",
|
DeviceMountPath: "/foo/bar",
|
||||||
DeviceStagePath: "/foo/bar",
|
DeviceStagePath: "/foo/bar",
|
||||||
DevicePath: "/mnt/foobar",
|
DevicePath: "/mnt/foobar",
|
||||||
CSIVolumePhase: tc.volumePhase,
|
|
||||||
}
|
}
|
||||||
csiSource, _ := getCSISourceFromSpec(resizeOptions.VolumeSpec)
|
csiSource, _ := getCSISourceFromSpec(resizeOptions.VolumeSpec)
|
||||||
csClient := setupClientWithExpansion(t, tc.nodeStageSet, tc.nodeExpansion)
|
csClient := setupClientWithExpansion(t, tc.nodeStageSet, tc.nodeExpansion)
|
||||||
|
@ -53,9 +53,6 @@ type ProbeEvent struct {
|
|||||||
Op ProbeOperation // The operation to the plugin
|
Op ProbeOperation // The operation to the plugin
|
||||||
}
|
}
|
||||||
|
|
||||||
// CSIVolumePhaseType stores information about CSI volume path.
|
|
||||||
type CSIVolumePhaseType string
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// Common parameter which can be specified in StorageClass to specify the desired FSType
|
// 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
|
// Provisioners SHOULD implement support for this if they are block device based
|
||||||
@ -65,8 +62,6 @@ const (
|
|||||||
|
|
||||||
ProbeAddOrUpdate ProbeOperation = 1 << iota
|
ProbeAddOrUpdate ProbeOperation = 1 << iota
|
||||||
ProbeRemove
|
ProbeRemove
|
||||||
CSIVolumeStaged CSIVolumePhaseType = "staged"
|
|
||||||
CSIVolumePublished CSIVolumePhaseType = "published"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -124,9 +119,6 @@ type NodeResizeOptions struct {
|
|||||||
|
|
||||||
NewSize resource.Quantity
|
NewSize resource.Quantity
|
||||||
OldSize resource.Quantity
|
OldSize resource.Quantity
|
||||||
|
|
||||||
// CSIVolumePhase contains volume phase on the node
|
|
||||||
CSIVolumePhase CSIVolumePhaseType
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type DynamicPluginProber interface {
|
type DynamicPluginProber interface {
|
||||||
|
@ -478,12 +478,7 @@ func (plugin *FakeVolumePlugin) NodeExpand(resizeOptions NodeResizeOptions) (boo
|
|||||||
return false, fmt.Errorf("Test failure: NodeExpand")
|
return false, fmt.Errorf("Test failure: NodeExpand")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up fakeVolumePlugin not support STAGE_UNSTAGE for testing the behavior
|
if resizeOptions.VolumeSpec.Name() == FailVolumeExpansion {
|
||||||
// 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 {
|
|
||||||
return false, fmt.Errorf("fail volume expansion for volume: %s", FailVolumeExpansion)
|
return false, fmt.Errorf("fail volume expansion for volume: %s", FailVolumeExpansion)
|
||||||
}
|
}
|
||||||
return true, nil
|
return true, nil
|
||||||
|
@ -710,7 +710,6 @@ func (og *operationGenerator) GenerateMountVolumeFunc(
|
|||||||
}
|
}
|
||||||
klog.V(verbosity).InfoS(detailedMsg, "pod", klog.KObj(volumeToMount.Pod))
|
klog.V(verbosity).InfoS(detailedMsg, "pod", klog.KObj(volumeToMount.Pod))
|
||||||
resizeOptions.DeviceMountPath = volumeMounter.GetPath()
|
resizeOptions.DeviceMountPath = volumeMounter.GetPath()
|
||||||
resizeOptions.CSIVolumePhase = volume.CSIVolumePublished
|
|
||||||
|
|
||||||
_, resizeError = og.nodeExpandVolume(volumeToMount, actualStateOfWorld, resizeOptions)
|
_, resizeError = og.nodeExpandVolume(volumeToMount, actualStateOfWorld, resizeOptions)
|
||||||
if resizeError != nil {
|
if resizeError != nil {
|
||||||
@ -1204,7 +1203,6 @@ func (og *operationGenerator) GenerateMapVolumeFunc(
|
|||||||
resizeOptions := volume.NodeResizeOptions{
|
resizeOptions := volume.NodeResizeOptions{
|
||||||
DevicePath: devicePath,
|
DevicePath: devicePath,
|
||||||
DeviceStagePath: stagingPath,
|
DeviceStagePath: stagingPath,
|
||||||
CSIVolumePhase: volume.CSIVolumePublished,
|
|
||||||
}
|
}
|
||||||
_, resizeError := og.nodeExpandVolume(volumeToMount, actualStateOfWorld, resizeOptions)
|
_, resizeError := og.nodeExpandVolume(volumeToMount, actualStateOfWorld, resizeOptions)
|
||||||
if resizeError != nil {
|
if resizeError != nil {
|
||||||
@ -1974,7 +1972,6 @@ func (og *operationGenerator) GenerateExpandInUseVolumeFunc(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if we are doing online expansion then volume is already published
|
// if we are doing online expansion then volume is already published
|
||||||
resizeOptions.CSIVolumePhase = volume.CSIVolumePublished
|
|
||||||
resizeDone, eventErr, detailedErr = og.doOnlineExpansion(volumeToMount, actualStateOfWorld, resizeOptions)
|
resizeDone, eventErr, detailedErr = og.doOnlineExpansion(volumeToMount, actualStateOfWorld, resizeOptions)
|
||||||
if eventErr != nil || detailedErr != nil {
|
if eventErr != nil || detailedErr != nil {
|
||||||
return volumetypes.NewOperationContext(eventErr, detailedErr, migrated)
|
return volumetypes.NewOperationContext(eventErr, detailedErr, migrated)
|
||||||
|
Loading…
Reference in New Issue
Block a user