remove RetroactiveDefaultStorageClass feature gate checks
This commit is contained in:
@@ -2019,18 +2019,15 @@ type PersistentVolumeClaimSpecValidationOptions struct {
|
|||||||
AllowReadWriteOncePod bool
|
AllowReadWriteOncePod bool
|
||||||
// Allow users to recover from previously failing expansion operation
|
// Allow users to recover from previously failing expansion operation
|
||||||
EnableRecoverFromExpansionFailure bool
|
EnableRecoverFromExpansionFailure bool
|
||||||
// Allow assigning StorageClass to unbound PVCs retroactively
|
|
||||||
EnableRetroactiveDefaultStorageClass bool
|
|
||||||
// Allow to validate the label value of the label selector
|
// Allow to validate the label value of the label selector
|
||||||
AllowInvalidLabelValueInSelector bool
|
AllowInvalidLabelValueInSelector bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func ValidationOptionsForPersistentVolumeClaim(pvc, oldPvc *core.PersistentVolumeClaim) PersistentVolumeClaimSpecValidationOptions {
|
func ValidationOptionsForPersistentVolumeClaim(pvc, oldPvc *core.PersistentVolumeClaim) PersistentVolumeClaimSpecValidationOptions {
|
||||||
opts := PersistentVolumeClaimSpecValidationOptions{
|
opts := PersistentVolumeClaimSpecValidationOptions{
|
||||||
AllowReadWriteOncePod: utilfeature.DefaultFeatureGate.Enabled(features.ReadWriteOncePod),
|
AllowReadWriteOncePod: utilfeature.DefaultFeatureGate.Enabled(features.ReadWriteOncePod),
|
||||||
EnableRecoverFromExpansionFailure: utilfeature.DefaultFeatureGate.Enabled(features.RecoverVolumeExpansionFailure),
|
EnableRecoverFromExpansionFailure: utilfeature.DefaultFeatureGate.Enabled(features.RecoverVolumeExpansionFailure),
|
||||||
EnableRetroactiveDefaultStorageClass: utilfeature.DefaultFeatureGate.Enabled(features.RetroactiveDefaultStorageClass),
|
AllowInvalidLabelValueInSelector: false,
|
||||||
AllowInvalidLabelValueInSelector: false,
|
|
||||||
}
|
}
|
||||||
if oldPvc == nil {
|
if oldPvc == nil {
|
||||||
// If there's no old PVC, use the options based solely on feature enablement
|
// 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
|
// 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:
|
// StorageClassName only if following four conditions are met at the same time:
|
||||||
// 1. RetroactiveDefaultStorageClass FeatureGate is enabled
|
// 1. The new pvc's StorageClassName is not nil
|
||||||
// 2. The new pvc's StorageClassName is not nil
|
// 2. The old pvc's StorageClassName is nil
|
||||||
// 3. 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
|
||||||
// 4. 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 {
|
func validateStorageClassUpgradeFromNil(oldAnnotations map[string]string, oldScName, newScName *string, opts PersistentVolumeClaimSpecValidationOptions) bool {
|
||||||
oldAnnotation, oldAnnotationExist := oldAnnotations[core.BetaStorageClassAnnotation]
|
oldAnnotation, oldAnnotationExist := oldAnnotations[core.BetaStorageClassAnnotation]
|
||||||
return opts.EnableRetroactiveDefaultStorageClass /* condition 1 */ &&
|
return newScName != nil /* condition 1 */ &&
|
||||||
newScName != nil /* condition 2 */ &&
|
oldScName == nil /* condition 2 */ &&
|
||||||
oldScName == nil /* condition 3 */ &&
|
(!oldAnnotationExist || *newScName == oldAnnotation) /* condition 3 */
|
||||||
(!oldAnnotationExist || *newScName == oldAnnotation) /* condition 4 */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var resizeStatusSet = sets.NewString(string(core.PersistentVolumeClaimNoExpansionInProgress),
|
var resizeStatusSet = sets.NewString(string(core.PersistentVolumeClaimNoExpansionInProgress),
|
||||||
|
@@ -353,18 +353,16 @@ func (ctrl *PersistentVolumeController) syncUnboundClaim(ctx context.Context, cl
|
|||||||
// No PV could be found
|
// No PV could be found
|
||||||
// OBSERVATION: pvc is "Pending", will retry
|
// OBSERVATION: pvc is "Pending", will retry
|
||||||
|
|
||||||
if utilfeature.DefaultFeatureGate.Enabled(features.RetroactiveDefaultStorageClass) {
|
logger.V(4).Info("Attempting to assign storage class to unbound PersistentVolumeClaim", "PVC", klog.KObj(claim))
|
||||||
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)
|
||||||
updated, err := ctrl.assignDefaultStorageClass(ctx, claim)
|
if err != nil {
|
||||||
if err != nil {
|
metrics.RecordRetroactiveStorageClassMetric(false)
|
||||||
metrics.RecordRetroactiveStorageClassMetric(false)
|
return fmt.Errorf("can't update PersistentVolumeClaim[%q]: %w", claimToClaimKey(claim), err)
|
||||||
return fmt.Errorf("can't update PersistentVolumeClaim[%q]: %w", claimToClaimKey(claim), err)
|
}
|
||||||
}
|
if updated {
|
||||||
if updated {
|
logger.V(4).Info("PersistentVolumeClaim update successful, restarting claim sync", "PVC", klog.KObj(claim))
|
||||||
logger.V(4).Info("PersistentVolumeClaim update successful, restarting claim sync", "PVC", klog.KObj(claim))
|
metrics.RecordRetroactiveStorageClassMetric(true)
|
||||||
metrics.RecordRetroactiveStorageClassMetric(true)
|
return nil
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
|
Reference in New Issue
Block a user