volumeattributesclass and core api changes

This commit is contained in:
carlory
2023-10-31 10:12:02 +08:00
parent f5a5d83d7c
commit ae90a69677
28 changed files with 2171 additions and 84 deletions

View File

@@ -35,6 +35,14 @@ const (
// DropDisabledFields removes disabled fields from the pvc spec.
// This should be called from PrepareForCreate/PrepareForUpdate for all resources containing a pvc spec.
func DropDisabledFields(pvcSpec, oldPVCSpec *core.PersistentVolumeClaimSpec) {
// Drop the contents of the volumeAttributesClassName if the VolumeAttributesClass
// feature gate is disabled.
if !utilfeature.DefaultFeatureGate.Enabled(features.VolumeAttributesClass) {
if oldPVCSpec == nil || oldPVCSpec.VolumeAttributesClassName == nil {
pvcSpec.VolumeAttributesClassName = nil
}
}
// Drop the contents of the dataSourceRef field if the AnyVolumeDataSource
// feature gate is disabled.
if !utilfeature.DefaultFeatureGate.Enabled(features.AnyVolumeDataSource) {
@@ -91,6 +99,15 @@ func EnforceDataSourceBackwardsCompatibility(pvcSpec, oldPVCSpec *core.Persisten
}
func DropDisabledFieldsFromStatus(pvc, oldPVC *core.PersistentVolumeClaim) {
if !utilfeature.DefaultFeatureGate.Enabled(features.VolumeAttributesClass) {
if oldPVC == nil || oldPVC.Status.CurrentVolumeAttributesClassName == nil {
pvc.Status.CurrentVolumeAttributesClassName = nil
}
if oldPVC == nil || oldPVC.Status.ModifyVolumeStatus == nil {
pvc.Status.ModifyVolumeStatus = nil
}
}
if !utilfeature.DefaultFeatureGate.Enabled(features.RecoverVolumeExpansionFailure) {
if !helper.ClaimContainsAllocatedResources(oldPVC) {
pvc.Status.AllocatedResources = nil