Skip to content

Commit 5572688

Browse files
authored
Merge pull request kubernetes#128342 from gnufied/recovery-expansion-beta
Move RecoverVolumeExpansionFailure feature to beta
2 parents a2b19b3 + 2d58d4e commit 5572688

File tree

7 files changed

+33
-6
lines changed

7 files changed

+33
-6
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
@@ -509,6 +509,7 @@ const (
509509

510510
// owner: @gnufied
511511
// kep: https://kep.k8s.io/1790
512+
// beta - v1.32
512513
//
513514
// Allow users to recover from volume expansion failure
514515
RecoverVolumeExpansionFailure featuregate.Feature = "RecoverVolumeExpansionFailure"

pkg/features/versioned_kube_features.go

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

597597
RecoverVolumeExpansionFailure: {
598598
{Version: version.MustParse("1.23"), Default: false, PreRelease: featuregate.Alpha},
599+
{Version: version.MustParse("1.32"), Default: true, PreRelease: featuregate.Beta},
599600
},
600601
RecursiveReadOnlyMounts: {
601602
{Version: version.MustParse("1.30"), Default: false, PreRelease: featuregate.Alpha},

pkg/volume/util/operationexecutor/node_expander.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
clientset "k8s.io/client-go/kubernetes"
2525
"k8s.io/client-go/tools/record"
2626
"k8s.io/klog/v2"
27+
"k8s.io/kubectl/pkg/util/storage"
2728
kevents "k8s.io/kubernetes/pkg/kubelet/events"
2829
"k8s.io/kubernetes/pkg/volume/util"
2930
volumetypes "k8s.io/kubernetes/pkg/volume/util/types"
@@ -97,7 +98,9 @@ func (ne *NodeExpander) runPreCheck() bool {
9798

9899
// PVC is already expanded but we are still trying to expand the volume because
99100
// 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 == "" {
101+
if ne.pvcStatusCap.Cmp(ne.pluginResizeOpts.NewSize) >= 0 &&
102+
ne.resizeStatus == "" &&
103+
storage.ContainsAccessMode(ne.pvc.Spec.AccessModes, v1.ReadWriteMany) {
101104
ne.pvcAlreadyUpdated = true
102105
return true
103106
}

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: "RWX 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: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ func TestOperationGenerator_nodeExpandVolume(t *testing.T) {
255255
actualSize: getSizeFunc("1G"),
256256

257257
expectedResizeStatus: "",
258-
resizeCallCount: 1,
258+
resizeCallCount: 0,
259259
expectedStatusSize: resource.MustParse("2G"),
260260
},
261261
{
@@ -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{

test/featuregates_linter/test_data/versioned_feature_list.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,6 +964,10 @@
964964
lockToDefault: false
965965
preRelease: Alpha
966966
version: "1.23"
967+
- default: true
968+
lockToDefault: false
969+
preRelease: Beta
970+
version: "1.32"
967971
- name: RecursiveReadOnlyMounts
968972
versionedSpecs:
969973
- default: false

0 commit comments

Comments
 (0)