mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-21 18:11:22 +00:00
Mark volume mount as uncertain in case of volume expansion fails
should mark volume mount in actual state even if volume expansion fails so that reconciler can tear down the volume when needed. To avoid pods start using it, mark volume as uncertain instead of mounted. Will add unit test after the logic is reviewed. Change-Id: I5aebfa11ec93235a87af8f17bea7f7b1570b603d
This commit is contained in:
@@ -81,6 +81,8 @@ const (
|
||||
// FailWithInUseVolumeName will cause NodeExpandVolume to result in FailedPrecondition error
|
||||
FailWithInUseVolumeName = "fail-expansion-in-use"
|
||||
|
||||
FailVolumeExpansion = "fail-expansion-test"
|
||||
|
||||
deviceNotMounted = "deviceNotMounted"
|
||||
deviceMountUncertain = "deviceMountUncertain"
|
||||
deviceMounted = "deviceMounted"
|
||||
@@ -467,6 +469,14 @@ func (plugin *FakeVolumePlugin) NodeExpand(resizeOptions NodeResizeOptions) (boo
|
||||
if resizeOptions.VolumeSpec.Name() == FailWithInUseVolumeName {
|
||||
return false, volumetypes.NewFailedPreconditionError("volume-in-use")
|
||||
}
|
||||
// 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 {
|
||||
return false, fmt.Errorf("fail volume expansion for volume: %s", FailVolumeExpansion)
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user