Skip to content

Commit a9d71bd

Browse files
committed
Move RecoverVolumeExpansionFailure feature to beta
1 parent 7b7a796 commit a9d71bd

File tree

6 files changed

+41
-5
lines changed

6 files changed

+41
-5
lines changed

pkg/apis/core/validation/validation_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3066,35 +3066,37 @@ func TestValidationOptionsForPersistentVolumeClaim(t *testing.T) {
30663066
"nil pv": {
30673067
oldPvc: nil,
30683068
expectValidationOpts: PersistentVolumeClaimSpecValidationOptions{
3069-
EnableRecoverFromExpansionFailure: false,
3069+
EnableRecoverFromExpansionFailure: true,
30703070
EnableVolumeAttributesClass: false,
30713071
},
30723072
},
30733073
"invaild apiGroup in dataSource allowed because the old pvc is used": {
30743074
oldPvc: pvcWithDataSource(&core.TypedLocalObjectReference{APIGroup: &invaildAPIGroup}),
30753075
expectValidationOpts: PersistentVolumeClaimSpecValidationOptions{
3076+
EnableRecoverFromExpansionFailure: true,
30763077
AllowInvalidAPIGroupInDataSourceOrRef: true,
30773078
},
30783079
},
30793080
"invaild apiGroup in dataSourceRef allowed because the old pvc is used": {
30803081
oldPvc: pvcWithDataSourceRef(&core.TypedObjectReference{APIGroup: &invaildAPIGroup}),
30813082
expectValidationOpts: PersistentVolumeClaimSpecValidationOptions{
3083+
EnableRecoverFromExpansionFailure: true,
30823084
AllowInvalidAPIGroupInDataSourceOrRef: true,
30833085
},
30843086
},
30853087
"volume attributes class allowed because feature enable": {
30863088
oldPvc: pvcWithVolumeAttributesClassName(utilpointer.String("foo")),
30873089
enableVolumeAttributesClass: true,
30883090
expectValidationOpts: PersistentVolumeClaimSpecValidationOptions{
3089-
EnableRecoverFromExpansionFailure: false,
3091+
EnableRecoverFromExpansionFailure: true,
30903092
EnableVolumeAttributesClass: true,
30913093
},
30923094
},
30933095
"volume attributes class validated because used and feature disabled": {
30943096
oldPvc: pvcWithVolumeAttributesClassName(utilpointer.String("foo")),
30953097
enableVolumeAttributesClass: false,
30963098
expectValidationOpts: PersistentVolumeClaimSpecValidationOptions{
3097-
EnableRecoverFromExpansionFailure: false,
3099+
EnableRecoverFromExpansionFailure: true,
30983100
EnableVolumeAttributesClass: true,
30993101
},
31003102
},

pkg/features/kube_features.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,7 @@ const (
488488

489489
// owner: @gnufied
490490
// kep: https://kep.k8s.io/1790
491+
// beta - v1.32
491492
//
492493
// Allow users to recover from volume expansion failure
493494
RecoverVolumeExpansionFailure featuregate.Feature = "RecoverVolumeExpansionFailure"

pkg/features/versioned_kube_features.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,7 @@ var defaultVersionedKubernetesFeatureGates = map[featuregate.Feature]featuregate
592592

593593
RecoverVolumeExpansionFailure: {
594594
{Version: version.MustParse("1.23"), Default: false, PreRelease: featuregate.Alpha},
595+
{Version: version.MustParse("1.32"), Default: true, PreRelease: featuregate.Beta},
595596
},
596597
RecursiveReadOnlyMounts: {
597598
{Version: version.MustParse("1.30"), Default: false, PreRelease: featuregate.Alpha},

pkg/volume/util/operationexecutor/node_expander.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ func (ne *NodeExpander) runPreCheck() bool {
9797

9898
// PVC is already expanded but we are still trying to expand the volume because
9999
// last recorded size in ASOW is older. This can happen for RWX volume types.
100-
if ne.pvcStatusCap.Cmp(ne.pluginResizeOpts.NewSize) >= 0 && ne.resizeStatus == "" {
100+
if ne.pvcStatusCap.Cmp(ne.pluginResizeOpts.NewSize) >= 0 &&
101+
ne.resizeStatus == "" &&
102+
ne.hasReadWriteMany() {
101103
ne.pvcAlreadyUpdated = true
102104
return true
103105
}
@@ -118,6 +120,20 @@ func (ne *NodeExpander) runPreCheck() bool {
118120
return false
119121
}
120122

123+
func (ne *NodeExpander) hasReadWriteMany() bool {
124+
accessModes := ne.pvc.Spec.AccessModes
125+
if accessModes == nil {
126+
return false
127+
}
128+
129+
for _, mode := range accessModes {
130+
if mode == v1.ReadWriteMany {
131+
return true
132+
}
133+
}
134+
return false
135+
}
136+
121137
func (ne *NodeExpander) expandOnPlugin() (bool, resource.Quantity, error) {
122138
allowExpansion := ne.runPreCheck()
123139
if !allowExpansion {

pkg/volume/util/operationexecutor/node_expander_test.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,21 @@ func TestNodeExpander(t *testing.T) {
110110
expectedStatusSize: resource.MustParse("1G"),
111111
},
112112
{
113-
name: "pv.spec.cap = pvc.status.cap, resizeStatus='', desiredSize > actualSize",
113+
name: "RWO volumes, pv.spec.cap = pvc.status.cap, resizeStatus='', desiredSize > actualSize",
114114
pvc: getTestPVC("test-vol0", "2G", "2G", "2G", nil),
115115
pv: getTestPV("test-vol0", "2G"),
116116

117+
expectedResizeStatus: "",
118+
expectResizeCall: false,
119+
assumeResizeOpAsFinished: true,
120+
expectFinalErrors: false,
121+
expectedStatusSize: resource.MustParse("2G"),
122+
},
123+
{
124+
name: "RWOP volumes, pv.spec.cap = pvc.status.cap, resizeStatus='', desiredSize > actualSize",
125+
pvc: addAccessMode(getTestPVC("test-vol0", "2G", "2G", "2G", nil), v1.ReadWriteMany),
126+
pv: getTestPV("test-vol0", "2G"),
127+
117128
expectedResizeStatus: "",
118129
expectResizeCall: true,
119130
assumeResizeOpAsFinished: true,

pkg/volume/util/operationexecutor/operation_generator_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,11 @@ func getTestPVC(volumeName string, specSize, statusSize, allocatedSize string, r
455455
return pvc
456456
}
457457

458+
func addAccessMode(pvc *v1.PersistentVolumeClaim, mode v1.PersistentVolumeAccessMode) *v1.PersistentVolumeClaim {
459+
pvc.Spec.AccessModes = append(pvc.Spec.AccessModes, mode)
460+
return pvc
461+
}
462+
458463
func getTestPV(volumeName string, specSize string) *v1.PersistentVolume {
459464
return &v1.PersistentVolume{
460465
ObjectMeta: metav1.ObjectMeta{

0 commit comments

Comments
 (0)