Move RecoverVolumeExpansionFailure feature to beta

This commit is contained in:
Hemant Kumar 2024-10-25 13:39:43 -04:00
parent 7b7a7968d4
commit a9d71bd6e6
6 changed files with 41 additions and 5 deletions

View File

@ -3066,19 +3066,21 @@ func TestValidationOptionsForPersistentVolumeClaim(t *testing.T) {
"nil pv": {
oldPvc: nil,
expectValidationOpts: PersistentVolumeClaimSpecValidationOptions{
EnableRecoverFromExpansionFailure: false,
EnableRecoverFromExpansionFailure: true,
EnableVolumeAttributesClass: false,
},
},
"invaild apiGroup in dataSource allowed because the old pvc is used": {
oldPvc: pvcWithDataSource(&core.TypedLocalObjectReference{APIGroup: &invaildAPIGroup}),
expectValidationOpts: PersistentVolumeClaimSpecValidationOptions{
EnableRecoverFromExpansionFailure: true,
AllowInvalidAPIGroupInDataSourceOrRef: true,
},
},
"invaild apiGroup in dataSourceRef allowed because the old pvc is used": {
oldPvc: pvcWithDataSourceRef(&core.TypedObjectReference{APIGroup: &invaildAPIGroup}),
expectValidationOpts: PersistentVolumeClaimSpecValidationOptions{
EnableRecoverFromExpansionFailure: true,
AllowInvalidAPIGroupInDataSourceOrRef: true,
},
},
@ -3086,7 +3088,7 @@ func TestValidationOptionsForPersistentVolumeClaim(t *testing.T) {
oldPvc: pvcWithVolumeAttributesClassName(utilpointer.String("foo")),
enableVolumeAttributesClass: true,
expectValidationOpts: PersistentVolumeClaimSpecValidationOptions{
EnableRecoverFromExpansionFailure: false,
EnableRecoverFromExpansionFailure: true,
EnableVolumeAttributesClass: true,
},
},
@ -3094,7 +3096,7 @@ func TestValidationOptionsForPersistentVolumeClaim(t *testing.T) {
oldPvc: pvcWithVolumeAttributesClassName(utilpointer.String("foo")),
enableVolumeAttributesClass: false,
expectValidationOpts: PersistentVolumeClaimSpecValidationOptions{
EnableRecoverFromExpansionFailure: false,
EnableRecoverFromExpansionFailure: true,
EnableVolumeAttributesClass: true,
},
},

View File

@ -488,6 +488,7 @@ const (
// owner: @gnufied
// kep: https://kep.k8s.io/1790
// beta - v1.32
//
// Allow users to recover from volume expansion failure
RecoverVolumeExpansionFailure featuregate.Feature = "RecoverVolumeExpansionFailure"

View File

@ -592,6 +592,7 @@ var defaultVersionedKubernetesFeatureGates = map[featuregate.Feature]featuregate
RecoverVolumeExpansionFailure: {
{Version: version.MustParse("1.23"), Default: false, PreRelease: featuregate.Alpha},
{Version: version.MustParse("1.32"), Default: true, PreRelease: featuregate.Beta},
},
RecursiveReadOnlyMounts: {
{Version: version.MustParse("1.30"), Default: false, PreRelease: featuregate.Alpha},

View File

@ -97,7 +97,9 @@ func (ne *NodeExpander) runPreCheck() bool {
// PVC is already expanded but we are still trying to expand the volume because
// last recorded size in ASOW is older. This can happen for RWX volume types.
if ne.pvcStatusCap.Cmp(ne.pluginResizeOpts.NewSize) >= 0 && ne.resizeStatus == "" {
if ne.pvcStatusCap.Cmp(ne.pluginResizeOpts.NewSize) >= 0 &&
ne.resizeStatus == "" &&
ne.hasReadWriteMany() {
ne.pvcAlreadyUpdated = true
return true
}
@ -118,6 +120,20 @@ func (ne *NodeExpander) runPreCheck() bool {
return false
}
func (ne *NodeExpander) hasReadWriteMany() bool {
accessModes := ne.pvc.Spec.AccessModes
if accessModes == nil {
return false
}
for _, mode := range accessModes {
if mode == v1.ReadWriteMany {
return true
}
}
return false
}
func (ne *NodeExpander) expandOnPlugin() (bool, resource.Quantity, error) {
allowExpansion := ne.runPreCheck()
if !allowExpansion {

View File

@ -110,10 +110,21 @@ func TestNodeExpander(t *testing.T) {
expectedStatusSize: resource.MustParse("1G"),
},
{
name: "pv.spec.cap = pvc.status.cap, resizeStatus='', desiredSize > actualSize",
name: "RWO volumes, pv.spec.cap = pvc.status.cap, resizeStatus='', desiredSize > actualSize",
pvc: getTestPVC("test-vol0", "2G", "2G", "2G", nil),
pv: getTestPV("test-vol0", "2G"),
expectedResizeStatus: "",
expectResizeCall: false,
assumeResizeOpAsFinished: true,
expectFinalErrors: false,
expectedStatusSize: resource.MustParse("2G"),
},
{
name: "RWOP volumes, pv.spec.cap = pvc.status.cap, resizeStatus='', desiredSize > actualSize",
pvc: addAccessMode(getTestPVC("test-vol0", "2G", "2G", "2G", nil), v1.ReadWriteMany),
pv: getTestPV("test-vol0", "2G"),
expectedResizeStatus: "",
expectResizeCall: true,
assumeResizeOpAsFinished: true,

View File

@ -455,6 +455,11 @@ func getTestPVC(volumeName string, specSize, statusSize, allocatedSize string, r
return pvc
}
func addAccessMode(pvc *v1.PersistentVolumeClaim, mode v1.PersistentVolumeAccessMode) *v1.PersistentVolumeClaim {
pvc.Spec.AccessModes = append(pvc.Spec.AccessModes, mode)
return pvc
}
func getTestPV(volumeName string, specSize string) *v1.PersistentVolume {
return &v1.PersistentVolume{
ObjectMeta: metav1.ObjectMeta{