Update VolumePVCDatasource to GA for 1.18

Updates the VolumePVCDataSource featuregate (cloning) to GA for the 1.18 k8s
release.
This commit is contained in:
j-griffith 2020-03-03 10:37:20 -07:00
parent 861c918a44
commit 9044fbfc5d
8 changed files with 35 additions and 55 deletions

View File

@ -7832,7 +7832,7 @@
}, },
"dataSource": { "dataSource": {
"$ref": "#/definitions/io.k8s.api.core.v1.TypedLocalObjectReference", "$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": { "resources": {
"$ref": "#/definitions/io.k8s.api.core.v1.ResourceRequirements", "$ref": "#/definitions/io.k8s.api.core.v1.ResourceRequirements",

View File

@ -51,8 +51,7 @@ func dataSourceIsEnabled(pvcSpec *core.PersistentVolumeClaimSpec) bool {
if pvcSpec.DataSource.APIGroup != nil { if pvcSpec.DataSource.APIGroup != nil {
apiGroup = *pvcSpec.DataSource.APIGroup apiGroup = *pvcSpec.DataSource.APIGroup
} }
if utilfeature.DefaultFeatureGate.Enabled(features.VolumePVCDataSource) && if pvcSpec.DataSource.Kind == pvc &&
pvcSpec.DataSource.Kind == pvc &&
apiGroup == "" { apiGroup == "" {
return true return true

View File

@ -148,58 +148,32 @@ func TestPVCDataSourceSpecFilter(t *testing.T) {
} }
var tests = map[string]struct { var tests = map[string]struct {
spec core.PersistentVolumeClaimSpec spec core.PersistentVolumeClaimSpec
gateEnabled bool want *core.TypedLocalObjectReference
want *core.TypedLocalObjectReference
}{ }{
"enabled with empty ds": { "enabled with empty ds": {
spec: core.PersistentVolumeClaimSpec{}, spec: core.PersistentVolumeClaimSpec{},
gateEnabled: true, want: nil,
want: nil,
}, },
"enabled with invalid spec": { "enabled with invalid spec": {
spec: invalidSpec, spec: invalidSpec,
gateEnabled: true, want: nil,
want: nil,
}, },
"enabled with valid spec": { "enabled with valid spec": {
spec: validSpec, spec: validSpec,
gateEnabled: true, want: validSpec.DataSource,
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,
}, },
"enabled with valid spec but nil APIGroup": { "enabled with valid spec but nil APIGroup": {
spec: validSpecNilAPIGroup, spec: validSpecNilAPIGroup,
gateEnabled: true, want: validSpecNilAPIGroup.DataSource,
want: validSpecNilAPIGroup.DataSource,
},
"disabled with valid spec but nil APIGroup": {
spec: validSpecNilAPIGroup,
gateEnabled: false,
want: nil,
}, },
} }
for testName, test := range tests { for testName, test := range tests {
t.Run(testName, func(t *testing.T) { t.Run(testName, func(t *testing.T) {
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.VolumePVCDataSource, test.gateEnabled)()
DropDisabledFields(&test.spec, nil) DropDisabledFields(&test.spec, nil)
if test.spec.DataSource != test.want { 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)
} }
}) })

View File

@ -418,10 +418,10 @@ type PersistentVolumeClaimSpec struct {
// +optional // +optional
VolumeMode *PersistentVolumeMode VolumeMode *PersistentVolumeMode
// This field can be used to specify either: // 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) // * An existing PVC (PersistentVolumeClaim)
// In order to use either of these DataSource types, the appropriate feature gate // In order to use VolumeSnapshot object types, the appropriate feature gate
// must be enabled (VolumeSnapshotDataSource, VolumePVCDataSource) // must be enabled (VolumeSnapshotDataSource)
// If the provisioner can support the specified data source, it will create // 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. // 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 // If the provisioner does not support the specified data source, the volume will

View File

@ -477,6 +477,7 @@ const (
// owner: @j-griffith // owner: @j-griffith
// alpha: v1.15 // alpha: v1.15
// beta: v1.16 // beta: v1.16
// GA: v1.18
// //
// Enable support for specifying an existing PVC as a DataSource // Enable support for specifying an existing PVC as a DataSource
VolumePVCDataSource featuregate.Feature = "VolumePVCDataSource" VolumePVCDataSource featuregate.Feature = "VolumePVCDataSource"
@ -637,7 +638,7 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS
ServiceLoadBalancerFinalizer: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, ServiceLoadBalancerFinalizer: {Default: true, PreRelease: featuregate.GA, LockToDefault: true},
LocalStorageCapacityIsolationFSQuotaMonitoring: {Default: false, PreRelease: featuregate.Alpha}, LocalStorageCapacityIsolationFSQuotaMonitoring: {Default: false, PreRelease: featuregate.Alpha},
NonPreemptingPriority: {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}, PodOverhead: {Default: true, PreRelease: featuregate.Beta},
IPv6DualStack: {Default: false, PreRelease: featuregate.Alpha}, IPv6DualStack: {Default: false, PreRelease: featuregate.Alpha},
EndpointSlice: {Default: true, PreRelease: featuregate.Beta}, EndpointSlice: {Default: true, PreRelease: featuregate.Beta},

View File

@ -2637,11 +2637,14 @@ message PersistentVolumeClaimSpec {
// +optional // +optional
optional string volumeMode = 6; optional string volumeMode = 6;
// This field requires the VolumeSnapshotDataSource alpha feature gate to be // This field can be used to specify either:
// enabled and currently VolumeSnapshot is the only supported data source. // * An existing VolumeSnapshot object (snapshot.storage.k8s.io/VolumeSnapshot - Beta)
// If the provisioner can support VolumeSnapshot data source, it will create // * An existing PVC (PersistentVolumeClaim)
// a new volume and data will be restored to the volume at the same time. // In order to use VolumeSnapshot object types, the appropriate feature gate
// If the provisioner does not support VolumeSnapshot data source, volume will // 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. // 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 // In the future, we plan to support more data source types and the behavior
// of the provisioner may change. // of the provisioner may change.

View File

@ -461,11 +461,14 @@ type PersistentVolumeClaimSpec struct {
// Value of Filesystem is implied when not included in claim spec. // Value of Filesystem is implied when not included in claim spec.
// +optional // +optional
VolumeMode *PersistentVolumeMode `json:"volumeMode,omitempty" protobuf:"bytes,6,opt,name=volumeMode,casttype=PersistentVolumeMode"` VolumeMode *PersistentVolumeMode `json:"volumeMode,omitempty" protobuf:"bytes,6,opt,name=volumeMode,casttype=PersistentVolumeMode"`
// This field requires the VolumeSnapshotDataSource alpha feature gate to be // This field can be used to specify either:
// enabled and currently VolumeSnapshot is the only supported data source. // * An existing VolumeSnapshot object (snapshot.storage.k8s.io/VolumeSnapshot - Beta)
// If the provisioner can support VolumeSnapshot data source, it will create // * An existing PVC (PersistentVolumeClaim)
// a new volume and data will be restored to the volume at the same time. // In order to use VolumeSnapshot object types, the appropriate feature gate
// If the provisioner does not support VolumeSnapshot data source, volume will // 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. // 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 // In the future, we plan to support more data source types and the behavior
// of the provisioner may change. // of the provisioner may change.

View File

@ -1301,7 +1301,7 @@ var map_PersistentVolumeClaimSpec = map[string]string{
"volumeName": "VolumeName is the binding reference to the PersistentVolume backing this claim.", "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", "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.", "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 { func (PersistentVolumeClaimSpec) SwaggerDoc() map[string]string {