mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-13 22:05:59 +00:00
Move RecoverVolumeExpansionFailure feature to beta
This commit is contained in:
parent
7b7a7968d4
commit
a9d71bd6e6
@ -3066,19 +3066,21 @@ func TestValidationOptionsForPersistentVolumeClaim(t *testing.T) {
|
|||||||
"nil pv": {
|
"nil pv": {
|
||||||
oldPvc: nil,
|
oldPvc: nil,
|
||||||
expectValidationOpts: PersistentVolumeClaimSpecValidationOptions{
|
expectValidationOpts: PersistentVolumeClaimSpecValidationOptions{
|
||||||
EnableRecoverFromExpansionFailure: false,
|
EnableRecoverFromExpansionFailure: true,
|
||||||
EnableVolumeAttributesClass: false,
|
EnableVolumeAttributesClass: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"invaild apiGroup in dataSource allowed because the old pvc is used": {
|
"invaild apiGroup in dataSource allowed because the old pvc is used": {
|
||||||
oldPvc: pvcWithDataSource(&core.TypedLocalObjectReference{APIGroup: &invaildAPIGroup}),
|
oldPvc: pvcWithDataSource(&core.TypedLocalObjectReference{APIGroup: &invaildAPIGroup}),
|
||||||
expectValidationOpts: PersistentVolumeClaimSpecValidationOptions{
|
expectValidationOpts: PersistentVolumeClaimSpecValidationOptions{
|
||||||
|
EnableRecoverFromExpansionFailure: true,
|
||||||
AllowInvalidAPIGroupInDataSourceOrRef: true,
|
AllowInvalidAPIGroupInDataSourceOrRef: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"invaild apiGroup in dataSourceRef allowed because the old pvc is used": {
|
"invaild apiGroup in dataSourceRef allowed because the old pvc is used": {
|
||||||
oldPvc: pvcWithDataSourceRef(&core.TypedObjectReference{APIGroup: &invaildAPIGroup}),
|
oldPvc: pvcWithDataSourceRef(&core.TypedObjectReference{APIGroup: &invaildAPIGroup}),
|
||||||
expectValidationOpts: PersistentVolumeClaimSpecValidationOptions{
|
expectValidationOpts: PersistentVolumeClaimSpecValidationOptions{
|
||||||
|
EnableRecoverFromExpansionFailure: true,
|
||||||
AllowInvalidAPIGroupInDataSourceOrRef: true,
|
AllowInvalidAPIGroupInDataSourceOrRef: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -3086,7 +3088,7 @@ func TestValidationOptionsForPersistentVolumeClaim(t *testing.T) {
|
|||||||
oldPvc: pvcWithVolumeAttributesClassName(utilpointer.String("foo")),
|
oldPvc: pvcWithVolumeAttributesClassName(utilpointer.String("foo")),
|
||||||
enableVolumeAttributesClass: true,
|
enableVolumeAttributesClass: true,
|
||||||
expectValidationOpts: PersistentVolumeClaimSpecValidationOptions{
|
expectValidationOpts: PersistentVolumeClaimSpecValidationOptions{
|
||||||
EnableRecoverFromExpansionFailure: false,
|
EnableRecoverFromExpansionFailure: true,
|
||||||
EnableVolumeAttributesClass: true,
|
EnableVolumeAttributesClass: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -3094,7 +3096,7 @@ func TestValidationOptionsForPersistentVolumeClaim(t *testing.T) {
|
|||||||
oldPvc: pvcWithVolumeAttributesClassName(utilpointer.String("foo")),
|
oldPvc: pvcWithVolumeAttributesClassName(utilpointer.String("foo")),
|
||||||
enableVolumeAttributesClass: false,
|
enableVolumeAttributesClass: false,
|
||||||
expectValidationOpts: PersistentVolumeClaimSpecValidationOptions{
|
expectValidationOpts: PersistentVolumeClaimSpecValidationOptions{
|
||||||
EnableRecoverFromExpansionFailure: false,
|
EnableRecoverFromExpansionFailure: true,
|
||||||
EnableVolumeAttributesClass: true,
|
EnableVolumeAttributesClass: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -488,6 +488,7 @@ const (
|
|||||||
|
|
||||||
// owner: @gnufied
|
// owner: @gnufied
|
||||||
// kep: https://kep.k8s.io/1790
|
// kep: https://kep.k8s.io/1790
|
||||||
|
// beta - v1.32
|
||||||
//
|
//
|
||||||
// Allow users to recover from volume expansion failure
|
// Allow users to recover from volume expansion failure
|
||||||
RecoverVolumeExpansionFailure featuregate.Feature = "RecoverVolumeExpansionFailure"
|
RecoverVolumeExpansionFailure featuregate.Feature = "RecoverVolumeExpansionFailure"
|
||||||
|
@ -592,6 +592,7 @@ var defaultVersionedKubernetesFeatureGates = map[featuregate.Feature]featuregate
|
|||||||
|
|
||||||
RecoverVolumeExpansionFailure: {
|
RecoverVolumeExpansionFailure: {
|
||||||
{Version: version.MustParse("1.23"), Default: false, PreRelease: featuregate.Alpha},
|
{Version: version.MustParse("1.23"), Default: false, PreRelease: featuregate.Alpha},
|
||||||
|
{Version: version.MustParse("1.32"), Default: true, PreRelease: featuregate.Beta},
|
||||||
},
|
},
|
||||||
RecursiveReadOnlyMounts: {
|
RecursiveReadOnlyMounts: {
|
||||||
{Version: version.MustParse("1.30"), Default: false, PreRelease: featuregate.Alpha},
|
{Version: version.MustParse("1.30"), Default: false, PreRelease: featuregate.Alpha},
|
||||||
|
@ -97,7 +97,9 @@ func (ne *NodeExpander) runPreCheck() bool {
|
|||||||
|
|
||||||
// PVC is already expanded but we are still trying to expand the volume because
|
// 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.
|
// 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
|
ne.pvcAlreadyUpdated = true
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -118,6 +120,20 @@ func (ne *NodeExpander) runPreCheck() bool {
|
|||||||
return false
|
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) {
|
func (ne *NodeExpander) expandOnPlugin() (bool, resource.Quantity, error) {
|
||||||
allowExpansion := ne.runPreCheck()
|
allowExpansion := ne.runPreCheck()
|
||||||
if !allowExpansion {
|
if !allowExpansion {
|
||||||
|
@ -110,10 +110,21 @@ func TestNodeExpander(t *testing.T) {
|
|||||||
expectedStatusSize: resource.MustParse("1G"),
|
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),
|
pvc: getTestPVC("test-vol0", "2G", "2G", "2G", nil),
|
||||||
pv: getTestPV("test-vol0", "2G"),
|
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: "",
|
expectedResizeStatus: "",
|
||||||
expectResizeCall: true,
|
expectResizeCall: true,
|
||||||
assumeResizeOpAsFinished: true,
|
assumeResizeOpAsFinished: true,
|
||||||
|
@ -455,6 +455,11 @@ func getTestPVC(volumeName string, specSize, statusSize, allocatedSize string, r
|
|||||||
return pvc
|
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 {
|
func getTestPV(volumeName string, specSize string) *v1.PersistentVolume {
|
||||||
return &v1.PersistentVolume{
|
return &v1.PersistentVolume{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Loading…
Reference in New Issue
Block a user