From 9044fbfc5d7c737a209350946fd6b9f7ead897c6 Mon Sep 17 00:00:00 2001 From: j-griffith Date: Tue, 3 Mar 2020 10:37:20 -0700 Subject: [PATCH] Update VolumePVCDatasource to GA for 1.18 Updates the VolumePVCDataSource featuregate (cloning) to GA for the 1.18 k8s release. --- api/openapi-spec/swagger.json | 2 +- pkg/api/persistentvolumeclaim/util.go | 3 +- pkg/api/persistentvolumeclaim/util_test.go | 48 +++++-------------- pkg/apis/core/types.go | 6 +-- pkg/features/kube_features.go | 3 +- .../src/k8s.io/api/core/v1/generated.proto | 13 +++-- staging/src/k8s.io/api/core/v1/types.go | 13 +++-- .../core/v1/types_swagger_doc_generated.go | 2 +- 8 files changed, 35 insertions(+), 55 deletions(-) diff --git a/api/openapi-spec/swagger.json b/api/openapi-spec/swagger.json index 36cde2f94025..c375b0980b73 100644 --- a/api/openapi-spec/swagger.json +++ b/api/openapi-spec/swagger.json @@ -7832,7 +7832,7 @@ }, "dataSource": { "$ref": "#/definitions/io.k8s.api.core.v1.TypedLocalObjectReference", - "description": "This field requires the VolumeSnapshotDataSource alpha feature gate to be enabled and currently VolumeSnapshot is the only supported data source. If the provisioner can support VolumeSnapshot data source, it will create a new volume and data will be restored to the volume at the same time. If the provisioner does not support VolumeSnapshot data source, volume will not be created and the failure will be reported as an event. In the future, we plan to support more data source types and the behavior of the provisioner may change." + "description": "This field can be used to specify either: * An existing VolumeSnapshot object (snapshot.storage.k8s.io/VolumeSnapshot - Beta) * An existing PVC (PersistentVolumeClaim) In order to use VolumeSnapshot object types, the appropriate feature gate must be enabled (VolumeSnapshotDataSource) If the provisioner can support the specified data source, it will create a new volume based on the contents of the specified PVC or Snapshot. If the provisioner does not support the specified data source, the volume will not be created and the failure will be reported as an event. In the future, we plan to support more data source types and the behavior of the provisioner may change." }, "resources": { "$ref": "#/definitions/io.k8s.api.core.v1.ResourceRequirements", diff --git a/pkg/api/persistentvolumeclaim/util.go b/pkg/api/persistentvolumeclaim/util.go index 748641fa58e5..749b51f4883f 100644 --- a/pkg/api/persistentvolumeclaim/util.go +++ b/pkg/api/persistentvolumeclaim/util.go @@ -51,8 +51,7 @@ func dataSourceIsEnabled(pvcSpec *core.PersistentVolumeClaimSpec) bool { if pvcSpec.DataSource.APIGroup != nil { apiGroup = *pvcSpec.DataSource.APIGroup } - if utilfeature.DefaultFeatureGate.Enabled(features.VolumePVCDataSource) && - pvcSpec.DataSource.Kind == pvc && + if pvcSpec.DataSource.Kind == pvc && apiGroup == "" { return true diff --git a/pkg/api/persistentvolumeclaim/util_test.go b/pkg/api/persistentvolumeclaim/util_test.go index 108bb198174f..4a13ba1bd725 100644 --- a/pkg/api/persistentvolumeclaim/util_test.go +++ b/pkg/api/persistentvolumeclaim/util_test.go @@ -148,58 +148,32 @@ func TestPVCDataSourceSpecFilter(t *testing.T) { } var tests = map[string]struct { - spec core.PersistentVolumeClaimSpec - gateEnabled bool - want *core.TypedLocalObjectReference + spec core.PersistentVolumeClaimSpec + want *core.TypedLocalObjectReference }{ "enabled with empty ds": { - spec: core.PersistentVolumeClaimSpec{}, - gateEnabled: true, - want: nil, + spec: core.PersistentVolumeClaimSpec{}, + want: nil, }, "enabled with invalid spec": { - spec: invalidSpec, - gateEnabled: true, - want: nil, + spec: invalidSpec, + want: nil, }, "enabled with valid spec": { - spec: validSpec, - gateEnabled: true, - want: validSpec.DataSource, - }, - "disabled with invalid spec": { - spec: invalidSpec, - gateEnabled: false, - want: nil, - }, - "disabled with valid spec": { - spec: validSpec, - gateEnabled: false, - want: nil, - }, - "diabled with empty ds": { - spec: core.PersistentVolumeClaimSpec{}, - gateEnabled: false, - want: nil, + spec: validSpec, + want: validSpec.DataSource, }, "enabled with valid spec but nil APIGroup": { - spec: validSpecNilAPIGroup, - gateEnabled: true, - want: validSpecNilAPIGroup.DataSource, - }, - "disabled with valid spec but nil APIGroup": { - spec: validSpecNilAPIGroup, - gateEnabled: false, - want: nil, + spec: validSpecNilAPIGroup, + want: validSpecNilAPIGroup.DataSource, }, } for testName, test := range tests { t.Run(testName, func(t *testing.T) { - defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.VolumePVCDataSource, test.gateEnabled)() DropDisabledFields(&test.spec, nil) if test.spec.DataSource != test.want { - t.Errorf("expected drop datasource condition was not met, test: %s, gateEnabled: %v, spec: %v, expected: %v", testName, test.gateEnabled, test.spec, test.want) + t.Errorf("expected drop datasource condition was not met, test: %s, spec: %v, expected: %v", testName, test.spec, test.want) } }) diff --git a/pkg/apis/core/types.go b/pkg/apis/core/types.go index d412441cef4d..32e86d57d173 100644 --- a/pkg/apis/core/types.go +++ b/pkg/apis/core/types.go @@ -418,10 +418,10 @@ type PersistentVolumeClaimSpec struct { // +optional VolumeMode *PersistentVolumeMode // This field can be used to specify either: - // * An existing VolumeSnapshot object (snapshot.storage.k8s.io/VolumeSnapshot) + // * An existing VolumeSnapshot object (snapshot.storage.k8s.io/VolumeSnapshot - Beta) // * An existing PVC (PersistentVolumeClaim) - // In order to use either of these DataSource types, the appropriate feature gate - // must be enabled (VolumeSnapshotDataSource, VolumePVCDataSource) + // In order to use VolumeSnapshot object types, the appropriate feature gate + // must be enabled (VolumeSnapshotDataSource) // If the provisioner can support the specified data source, it will create // a new volume based on the contents of the specified PVC or Snapshot. // If the provisioner does not support the specified data source, the volume will diff --git a/pkg/features/kube_features.go b/pkg/features/kube_features.go index 64a27d8ea65f..18e76c462f98 100644 --- a/pkg/features/kube_features.go +++ b/pkg/features/kube_features.go @@ -477,6 +477,7 @@ const ( // owner: @j-griffith // alpha: v1.15 // beta: v1.16 + // GA: v1.18 // // Enable support for specifying an existing PVC as a DataSource VolumePVCDataSource featuregate.Feature = "VolumePVCDataSource" @@ -637,7 +638,7 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS ServiceLoadBalancerFinalizer: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, LocalStorageCapacityIsolationFSQuotaMonitoring: {Default: false, PreRelease: featuregate.Alpha}, NonPreemptingPriority: {Default: false, PreRelease: featuregate.Alpha}, - VolumePVCDataSource: {Default: true, PreRelease: featuregate.Beta}, + VolumePVCDataSource: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.20 PodOverhead: {Default: true, PreRelease: featuregate.Beta}, IPv6DualStack: {Default: false, PreRelease: featuregate.Alpha}, EndpointSlice: {Default: true, PreRelease: featuregate.Beta}, diff --git a/staging/src/k8s.io/api/core/v1/generated.proto b/staging/src/k8s.io/api/core/v1/generated.proto index 226971d89831..5f6787404f59 100644 --- a/staging/src/k8s.io/api/core/v1/generated.proto +++ b/staging/src/k8s.io/api/core/v1/generated.proto @@ -2637,11 +2637,14 @@ message PersistentVolumeClaimSpec { // +optional optional string volumeMode = 6; - // This field requires the VolumeSnapshotDataSource alpha feature gate to be - // enabled and currently VolumeSnapshot is the only supported data source. - // If the provisioner can support VolumeSnapshot data source, it will create - // a new volume and data will be restored to the volume at the same time. - // If the provisioner does not support VolumeSnapshot data source, volume will + // This field can be used to specify either: + // * An existing VolumeSnapshot object (snapshot.storage.k8s.io/VolumeSnapshot - Beta) + // * An existing PVC (PersistentVolumeClaim) + // In order to use VolumeSnapshot object types, the appropriate feature gate + // must be enabled (VolumeSnapshotDataSource) + // If the provisioner can support the specified data source, it will create + // a new volume based on the contents of the specified PVC or Snapshot. + // If the provisioner does not support the specified data source, the volume will // not be created and the failure will be reported as an event. // In the future, we plan to support more data source types and the behavior // of the provisioner may change. diff --git a/staging/src/k8s.io/api/core/v1/types.go b/staging/src/k8s.io/api/core/v1/types.go index 224183f23195..2bb9a2829691 100644 --- a/staging/src/k8s.io/api/core/v1/types.go +++ b/staging/src/k8s.io/api/core/v1/types.go @@ -461,11 +461,14 @@ type PersistentVolumeClaimSpec struct { // Value of Filesystem is implied when not included in claim spec. // +optional VolumeMode *PersistentVolumeMode `json:"volumeMode,omitempty" protobuf:"bytes,6,opt,name=volumeMode,casttype=PersistentVolumeMode"` - // This field requires the VolumeSnapshotDataSource alpha feature gate to be - // enabled and currently VolumeSnapshot is the only supported data source. - // If the provisioner can support VolumeSnapshot data source, it will create - // a new volume and data will be restored to the volume at the same time. - // If the provisioner does not support VolumeSnapshot data source, volume will + // This field can be used to specify either: + // * An existing VolumeSnapshot object (snapshot.storage.k8s.io/VolumeSnapshot - Beta) + // * An existing PVC (PersistentVolumeClaim) + // In order to use VolumeSnapshot object types, the appropriate feature gate + // must be enabled (VolumeSnapshotDataSource) + // If the provisioner can support the specified data source, it will create + // a new volume based on the contents of the specified PVC or Snapshot. + // If the provisioner does not support the specified data source, the volume will // not be created and the failure will be reported as an event. // In the future, we plan to support more data source types and the behavior // of the provisioner may change. diff --git a/staging/src/k8s.io/api/core/v1/types_swagger_doc_generated.go b/staging/src/k8s.io/api/core/v1/types_swagger_doc_generated.go index a5068e983d13..918c8bc04ca3 100644 --- a/staging/src/k8s.io/api/core/v1/types_swagger_doc_generated.go +++ b/staging/src/k8s.io/api/core/v1/types_swagger_doc_generated.go @@ -1301,7 +1301,7 @@ var map_PersistentVolumeClaimSpec = map[string]string{ "volumeName": "VolumeName is the binding reference to the PersistentVolume backing this claim.", "storageClassName": "Name of the StorageClass required by the claim. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#class-1", "volumeMode": "volumeMode defines what type of volume is required by the claim. Value of Filesystem is implied when not included in claim spec.", - "dataSource": "This field requires the VolumeSnapshotDataSource alpha feature gate to be enabled and currently VolumeSnapshot is the only supported data source. If the provisioner can support VolumeSnapshot data source, it will create a new volume and data will be restored to the volume at the same time. If the provisioner does not support VolumeSnapshot data source, volume will not be created and the failure will be reported as an event. In the future, we plan to support more data source types and the behavior of the provisioner may change.", + "dataSource": "This field can be used to specify either: * An existing VolumeSnapshot object (snapshot.storage.k8s.io/VolumeSnapshot - Beta) * An existing PVC (PersistentVolumeClaim) In order to use VolumeSnapshot object types, the appropriate feature gate must be enabled (VolumeSnapshotDataSource) If the provisioner can support the specified data source, it will create a new volume based on the contents of the specified PVC or Snapshot. If the provisioner does not support the specified data source, the volume will not be created and the failure will be reported as an event. In the future, we plan to support more data source types and the behavior of the provisioner may change.", } func (PersistentVolumeClaimSpec) SwaggerDoc() map[string]string {