mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 17:30:00 +00:00
Merge pull request #123055 from gnufied/fix-2-rwx-expand
Fix race condition between external-resizer and kubelet
This commit is contained in:
commit
440f11d83d
@ -1279,6 +1279,16 @@ func Test_Run_Positive_VolumeFSResizeControllerAttachEnabled(t *testing.T) {
|
|||||||
newPVSize: resource.MustParse("15G"),
|
newPVSize: resource.MustParse("15G"),
|
||||||
oldPVSize: resource.MustParse("13G"),
|
oldPVSize: resource.MustParse("13G"),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "expand-fs-volume with unsupported error",
|
||||||
|
volumeMode: &fsMode,
|
||||||
|
expansionFailed: false,
|
||||||
|
pvName: volumetesting.FailWithUnSupportedVolumeName,
|
||||||
|
pvcSize: resource.MustParse("10G"),
|
||||||
|
pvcStatusSize: resource.MustParse("10G"),
|
||||||
|
newPVSize: resource.MustParse("15G"),
|
||||||
|
oldPVSize: resource.MustParse("13G"),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range tests {
|
for _, tc := range tests {
|
||||||
|
@ -72,7 +72,7 @@ func (c *csiPlugin) nodeExpandWithClient(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !nodeExpandSet {
|
if !nodeExpandSet {
|
||||||
return false, fmt.Errorf("Expander.NodeExpand found CSI plugin %s/%s to not support node expansion", c.GetPluginName(), driverName)
|
return false, volumetypes.NewOperationNotSupportedError(fmt.Sprintf("NodeExpand is not supported by the CSI driver %s", driverName))
|
||||||
}
|
}
|
||||||
|
|
||||||
pv := resizeOptions.VolumeSpec.PersistentVolume
|
pv := resizeOptions.VolumeSpec.PersistentVolume
|
||||||
|
@ -83,7 +83,8 @@ const (
|
|||||||
SuccessAndFailOnMountDeviceName = "success-and-failed-mount-device-name"
|
SuccessAndFailOnMountDeviceName = "success-and-failed-mount-device-name"
|
||||||
|
|
||||||
// FailWithInUseVolumeName will cause NodeExpandVolume to result in FailedPrecondition error
|
// FailWithInUseVolumeName will cause NodeExpandVolume to result in FailedPrecondition error
|
||||||
FailWithInUseVolumeName = "fail-expansion-in-use"
|
FailWithInUseVolumeName = "fail-expansion-in-use"
|
||||||
|
FailWithUnSupportedVolumeName = "fail-expansion-unsupported"
|
||||||
|
|
||||||
FailVolumeExpansion = "fail-expansion-test"
|
FailVolumeExpansion = "fail-expansion-test"
|
||||||
|
|
||||||
@ -500,8 +501,12 @@ func (plugin *FakeVolumePlugin) NodeExpand(resizeOptions volume.NodeResizeOption
|
|||||||
if resizeOptions.VolumeSpec.Name() == FailWithInUseVolumeName {
|
if resizeOptions.VolumeSpec.Name() == FailWithInUseVolumeName {
|
||||||
return false, volumetypes.NewFailedPreconditionError("volume-in-use")
|
return false, volumetypes.NewFailedPreconditionError("volume-in-use")
|
||||||
}
|
}
|
||||||
|
if resizeOptions.VolumeSpec.Name() == FailWithUnSupportedVolumeName {
|
||||||
|
return false, volumetypes.NewOperationNotSupportedError("volume-unsupported")
|
||||||
|
}
|
||||||
|
|
||||||
if resizeOptions.VolumeSpec.Name() == AlwaysFailNodeExpansion {
|
if resizeOptions.VolumeSpec.Name() == AlwaysFailNodeExpansion {
|
||||||
return false, fmt.Errorf("Test failure: NodeExpand")
|
return false, fmt.Errorf("test failure: NodeExpand")
|
||||||
}
|
}
|
||||||
|
|
||||||
if resizeOptions.VolumeSpec.Name() == FailVolumeExpansion {
|
if resizeOptions.VolumeSpec.Name() == FailVolumeExpansion {
|
||||||
|
@ -2205,6 +2205,14 @@ func (og *operationGenerator) legacyCallNodeExpandOnPlugin(resizeOp nodeResizeOp
|
|||||||
|
|
||||||
_, resizeErr := expandableVolumePlugin.NodeExpand(rsOpts)
|
_, resizeErr := expandableVolumePlugin.NodeExpand(rsOpts)
|
||||||
if resizeErr != nil {
|
if resizeErr != nil {
|
||||||
|
// This is a workaround for now, until RecoverFromVolumeExpansionFailure feature goes GA.
|
||||||
|
// If RecoverFromVolumeExpansionFailure feature is enabled, we will not ever hit this state, because
|
||||||
|
// we will wait for VolumeExpansionPendingOnNode before trying to expand volume in kubelet.
|
||||||
|
if volumetypes.IsOperationNotSupportedError(resizeErr) {
|
||||||
|
klog.V(4).InfoS(volumeToMount.GenerateMsgDetailed("MountVolume.NodeExpandVolume failed", "NodeExpandVolume not supported"), "pod", klog.KObj(volumeToMount.Pod))
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|
||||||
// if driver returned FailedPrecondition error that means
|
// if driver returned FailedPrecondition error that means
|
||||||
// volume expansion should not be retried on this node but
|
// volume expansion should not be retried on this node but
|
||||||
// expansion operation should not block mounting
|
// expansion operation should not block mounting
|
||||||
|
@ -102,6 +102,23 @@ func IsFailedPreconditionError(err error) bool {
|
|||||||
return errors.As(err, &failedPreconditionError)
|
return errors.As(err, &failedPreconditionError)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type OperationNotSupported struct {
|
||||||
|
msg string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (err *OperationNotSupported) Error() string {
|
||||||
|
return err.msg
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewOperationNotSupportedError(msg string) *OperationNotSupported {
|
||||||
|
return &OperationNotSupported{msg: msg}
|
||||||
|
}
|
||||||
|
|
||||||
|
func IsOperationNotSupportedError(err error) bool {
|
||||||
|
var operationNotSupportedError *OperationNotSupported
|
||||||
|
return errors.As(err, &operationNotSupportedError)
|
||||||
|
}
|
||||||
|
|
||||||
// TransientOperationFailure indicates operation failed with a transient error
|
// TransientOperationFailure indicates operation failed with a transient error
|
||||||
// and may fix itself when retried.
|
// and may fix itself when retried.
|
||||||
type TransientOperationFailure struct {
|
type TransientOperationFailure struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user