Skip to content

Commit cb89d80

Browse files
authored
Merge pull request kubernetes#74769 from msau42/local-pv-ga
move local PV to GA
2 parents 738d29b + 5f0847b commit cb89d80

File tree

3 files changed

+3
-111
lines changed

3 files changed

+3
-111
lines changed

pkg/api/persistentvolume/util.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ func DropDisabledFields(pvSpec *api.PersistentVolumeSpec, oldPVSpec *api.Persist
2828
if !utilfeature.DefaultFeatureGate.Enabled(features.BlockVolume) && !volumeModeInUse(oldPVSpec) {
2929
pvSpec.VolumeMode = nil
3030
}
31-
if !utilfeature.DefaultFeatureGate.Enabled(features.PersistentLocalVolumes) && !persistentLocalVolumesInUse(oldPVSpec) {
32-
pvSpec.PersistentVolumeSource.Local = nil
33-
}
3431
if !utilfeature.DefaultFeatureGate.Enabled(features.CSIPersistentVolume) {
3532
// if this is a new PV, or the old PV didn't already have the CSI field, clear it
3633
if oldPVSpec == nil || oldPVSpec.PersistentVolumeSource.CSI == nil {
@@ -48,13 +45,3 @@ func volumeModeInUse(oldPVSpec *api.PersistentVolumeSpec) bool {
4845
}
4946
return false
5047
}
51-
52-
func persistentLocalVolumesInUse(oldPVSpec *api.PersistentVolumeSpec) bool {
53-
if oldPVSpec == nil {
54-
return false
55-
}
56-
if oldPVSpec.PersistentVolumeSource.Local != nil {
57-
return true
58-
}
59-
return false
60-
}

pkg/api/persistentvolume/util_test.go

Lines changed: 0 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ limitations under the License.
1717
package persistentvolume
1818

1919
import (
20-
"fmt"
2120
"reflect"
2221
"testing"
2322

@@ -153,99 +152,3 @@ func TestDropDisabledFields(t *testing.T) {
153152
})
154153
}
155154
}
156-
157-
func TestDropDisabledFieldsPersistentLocalVolume(t *testing.T) {
158-
pvWithoutLocalVolume := func() *api.PersistentVolume {
159-
return &api.PersistentVolume{
160-
Spec: api.PersistentVolumeSpec{
161-
PersistentVolumeSource: api.PersistentVolumeSource{
162-
Local: nil,
163-
},
164-
},
165-
}
166-
}
167-
pvWithLocalVolume := func() *api.PersistentVolume {
168-
fsType := "ext4"
169-
return &api.PersistentVolume{
170-
Spec: api.PersistentVolumeSpec{
171-
PersistentVolumeSource: api.PersistentVolumeSource{
172-
Local: &api.LocalVolumeSource{
173-
Path: "/a/b/c",
174-
FSType: &fsType,
175-
},
176-
},
177-
},
178-
}
179-
}
180-
181-
pvInfo := []struct {
182-
description string
183-
hasLocalVolume bool
184-
pv func() *api.PersistentVolume
185-
}{
186-
{
187-
description: "pv without LocalVolume",
188-
hasLocalVolume: false,
189-
pv: pvWithoutLocalVolume,
190-
},
191-
{
192-
description: "pv with LocalVolume",
193-
hasLocalVolume: true,
194-
pv: pvWithLocalVolume,
195-
},
196-
{
197-
description: "is nil",
198-
hasLocalVolume: false,
199-
pv: func() *api.PersistentVolume { return nil },
200-
},
201-
}
202-
203-
for _, enabled := range []bool{true, false} {
204-
for _, oldpvInfo := range pvInfo {
205-
for _, newpvInfo := range pvInfo {
206-
oldpvHasLocalVolume, oldpv := oldpvInfo.hasLocalVolume, oldpvInfo.pv()
207-
newpvHasLocalVolume, newpv := newpvInfo.hasLocalVolume, newpvInfo.pv()
208-
if newpv == nil {
209-
continue
210-
}
211-
212-
t.Run(fmt.Sprintf("feature enabled=%v, old pvc %v, new pvc %v", enabled, oldpvInfo.description, newpvInfo.description), func(t *testing.T) {
213-
defer utilfeaturetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.PersistentLocalVolumes, enabled)()
214-
215-
var oldpvSpec *api.PersistentVolumeSpec
216-
if oldpv != nil {
217-
oldpvSpec = &oldpv.Spec
218-
}
219-
DropDisabledFields(&newpv.Spec, oldpvSpec)
220-
221-
// old pv should never be changed
222-
if !reflect.DeepEqual(oldpv, oldpvInfo.pv()) {
223-
t.Errorf("old pv changed: %v", diff.ObjectReflectDiff(oldpv, oldpvInfo.pv()))
224-
}
225-
226-
switch {
227-
case enabled || oldpvHasLocalVolume:
228-
// new pv should not be changed if the feature is enabled, or if the old pv had LocalVolume source
229-
if !reflect.DeepEqual(newpv, newpvInfo.pv()) {
230-
t.Errorf("new pv changed: %v", diff.ObjectReflectDiff(newpv, newpvInfo.pv()))
231-
}
232-
case newpvHasLocalVolume:
233-
// new pv should be changed
234-
if reflect.DeepEqual(newpv, newpvInfo.pv()) {
235-
t.Errorf("new pv was not changed")
236-
}
237-
// new pv should not have LocalVolume
238-
if !reflect.DeepEqual(newpv, pvWithoutLocalVolume()) {
239-
t.Errorf("new pv had LocalVolume source: %v", diff.ObjectReflectDiff(newpv, pvWithoutLocalVolume()))
240-
}
241-
default:
242-
// new pv should not need to be changed
243-
if !reflect.DeepEqual(newpv, newpvInfo.pv()) {
244-
t.Errorf("new pv changed: %v", diff.ObjectReflectDiff(newpv, newpvInfo.pv()))
245-
}
246-
}
247-
})
248-
}
249-
}
250-
}
251-
}

pkg/features/kube_features.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ const (
8787

8888
// owner: @msau42
8989
// alpha: v1.7
90+
// beta: v1.10
91+
// ga: v1.14
9092
//
9193
// A new volume type that supports local disks on a node.
9294
PersistentLocalVolumes utilfeature.Feature = "PersistentLocalVolumes"
@@ -428,7 +430,7 @@ var defaultKubernetesFeatureGates = map[utilfeature.Feature]utilfeature.FeatureS
428430
TaintBasedEvictions: {Default: true, PreRelease: utilfeature.Beta},
429431
RotateKubeletServerCertificate: {Default: true, PreRelease: utilfeature.Beta},
430432
RotateKubeletClientCertificate: {Default: true, PreRelease: utilfeature.Beta},
431-
PersistentLocalVolumes: {Default: true, PreRelease: utilfeature.Beta},
433+
PersistentLocalVolumes: {Default: true, PreRelease: utilfeature.GA, LockToDefault: true}, // remove in 1.17
432434
LocalStorageCapacityIsolation: {Default: true, PreRelease: utilfeature.Beta},
433435
HugePages: {Default: true, PreRelease: utilfeature.GA, LockToDefault: true}, // remove in 1.16
434436
Sysctls: {Default: true, PreRelease: utilfeature.Beta},

0 commit comments

Comments
 (0)