Skip to content

Commit

Permalink
Merge pull request #88686 from j-griffith/upgrade_cloning_to_ga
Browse files Browse the repository at this point in the history
Mark PVCDataSource featuregate as GA
  • Loading branch information
k8s-ci-robot authored Mar 4, 2020
2 parents 5c5faed + 9044fbf commit e865c0b
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 55 deletions.
2 changes: 1 addition & 1 deletion api/openapi-spec/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions pkg/api/persistentvolumeclaim/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
48 changes: 11 additions & 37 deletions pkg/api/persistentvolumeclaim/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

})
Expand Down
6 changes: 3 additions & 3 deletions pkg/apis/core/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion pkg/features/kube_features.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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},
Expand Down
13 changes: 8 additions & 5 deletions staging/src/k8s.io/api/core/v1/generated.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions staging/src/k8s.io/api/core/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e865c0b

Please sign in to comment.