From ac15d697578c4eb5ca0e64aef4e75f5567ca6689 Mon Sep 17 00:00:00 2001 From: Roman Bednar Date: Wed, 7 Jun 2023 14:27:49 +0200 Subject: [PATCH] remove RetroactiveDefaultStorageClass feature gate checks --- pkg/apis/core/validation/validation.go | 23 ++++++++----------- .../volume/persistentvolume/pv_controller.go | 22 ++++++++---------- 2 files changed, 19 insertions(+), 26 deletions(-) diff --git a/pkg/apis/core/validation/validation.go b/pkg/apis/core/validation/validation.go index 6502d9c210a..2002ae1be92 100644 --- a/pkg/apis/core/validation/validation.go +++ b/pkg/apis/core/validation/validation.go @@ -2019,18 +2019,15 @@ type PersistentVolumeClaimSpecValidationOptions struct { AllowReadWriteOncePod bool // Allow users to recover from previously failing expansion operation EnableRecoverFromExpansionFailure bool - // Allow assigning StorageClass to unbound PVCs retroactively - EnableRetroactiveDefaultStorageClass bool // Allow to validate the label value of the label selector AllowInvalidLabelValueInSelector bool } func ValidationOptionsForPersistentVolumeClaim(pvc, oldPvc *core.PersistentVolumeClaim) PersistentVolumeClaimSpecValidationOptions { opts := PersistentVolumeClaimSpecValidationOptions{ - AllowReadWriteOncePod: utilfeature.DefaultFeatureGate.Enabled(features.ReadWriteOncePod), - EnableRecoverFromExpansionFailure: utilfeature.DefaultFeatureGate.Enabled(features.RecoverVolumeExpansionFailure), - EnableRetroactiveDefaultStorageClass: utilfeature.DefaultFeatureGate.Enabled(features.RetroactiveDefaultStorageClass), - AllowInvalidLabelValueInSelector: false, + AllowReadWriteOncePod: utilfeature.DefaultFeatureGate.Enabled(features.ReadWriteOncePod), + EnableRecoverFromExpansionFailure: utilfeature.DefaultFeatureGate.Enabled(features.RecoverVolumeExpansionFailure), + AllowInvalidLabelValueInSelector: false, } if oldPvc == nil { // If there's no old PVC, use the options based solely on feature enablement @@ -2286,16 +2283,14 @@ func validateStorageClassUpgradeFromAnnotation(oldAnnotations, newAnnotations ma // Provide an upgrade path from PVC with nil storage class. We allow update of // StorageClassName only if following four conditions are met at the same time: -// 1. RetroactiveDefaultStorageClass FeatureGate is enabled -// 2. The new pvc's StorageClassName is not nil -// 3. The old pvc's StorageClassName is nil -// 4. The old pvc either does not have beta annotation set, or the beta annotation matches new pvc's StorageClassName +// 1. The new pvc's StorageClassName is not nil +// 2. The old pvc's StorageClassName is nil +// 3. The old pvc either does not have beta annotation set, or the beta annotation matches new pvc's StorageClassName func validateStorageClassUpgradeFromNil(oldAnnotations map[string]string, oldScName, newScName *string, opts PersistentVolumeClaimSpecValidationOptions) bool { oldAnnotation, oldAnnotationExist := oldAnnotations[core.BetaStorageClassAnnotation] - return opts.EnableRetroactiveDefaultStorageClass /* condition 1 */ && - newScName != nil /* condition 2 */ && - oldScName == nil /* condition 3 */ && - (!oldAnnotationExist || *newScName == oldAnnotation) /* condition 4 */ + return newScName != nil /* condition 1 */ && + oldScName == nil /* condition 2 */ && + (!oldAnnotationExist || *newScName == oldAnnotation) /* condition 3 */ } var resizeStatusSet = sets.NewString(string(core.PersistentVolumeClaimNoExpansionInProgress), diff --git a/pkg/controller/volume/persistentvolume/pv_controller.go b/pkg/controller/volume/persistentvolume/pv_controller.go index 562b2e0ab80..e5b69b23bd5 100644 --- a/pkg/controller/volume/persistentvolume/pv_controller.go +++ b/pkg/controller/volume/persistentvolume/pv_controller.go @@ -353,18 +353,16 @@ func (ctrl *PersistentVolumeController) syncUnboundClaim(ctx context.Context, cl // No PV could be found // OBSERVATION: pvc is "Pending", will retry - if utilfeature.DefaultFeatureGate.Enabled(features.RetroactiveDefaultStorageClass) { - logger.V(4).Info("FeatureGate is enabled, attempting to assign storage class to unbound PersistentVolumeClaim", "featureGate", features.RetroactiveDefaultStorageClass, "PVC", klog.KObj(claim)) - updated, err := ctrl.assignDefaultStorageClass(ctx, claim) - if err != nil { - metrics.RecordRetroactiveStorageClassMetric(false) - return fmt.Errorf("can't update PersistentVolumeClaim[%q]: %w", claimToClaimKey(claim), err) - } - if updated { - logger.V(4).Info("PersistentVolumeClaim update successful, restarting claim sync", "PVC", klog.KObj(claim)) - metrics.RecordRetroactiveStorageClassMetric(true) - return nil - } + logger.V(4).Info("Attempting to assign storage class to unbound PersistentVolumeClaim", "PVC", klog.KObj(claim)) + updated, err := ctrl.assignDefaultStorageClass(ctx, claim) + if err != nil { + metrics.RecordRetroactiveStorageClassMetric(false) + return fmt.Errorf("can't update PersistentVolumeClaim[%q]: %w", claimToClaimKey(claim), err) + } + if updated { + logger.V(4).Info("PersistentVolumeClaim update successful, restarting claim sync", "PVC", klog.KObj(claim)) + metrics.RecordRetroactiveStorageClassMetric(true) + return nil } switch {