mirror of https://github.com/k3s-io/k3s
Merge pull request #74830 from msau42/lock-csi-ga
lock csi and plugin watcher GA feature gatespull/564/head
commit
5bc1e9b8ea
|
@ -28,12 +28,6 @@ func DropDisabledFields(pvSpec *api.PersistentVolumeSpec, oldPVSpec *api.Persist
|
||||||
if !utilfeature.DefaultFeatureGate.Enabled(features.BlockVolume) && !volumeModeInUse(oldPVSpec) {
|
if !utilfeature.DefaultFeatureGate.Enabled(features.BlockVolume) && !volumeModeInUse(oldPVSpec) {
|
||||||
pvSpec.VolumeMode = nil
|
pvSpec.VolumeMode = nil
|
||||||
}
|
}
|
||||||
if !utilfeature.DefaultFeatureGate.Enabled(features.CSIPersistentVolume) {
|
|
||||||
// if this is a new PV, or the old PV didn't already have the CSI field, clear it
|
|
||||||
if oldPVSpec == nil || oldPVSpec.PersistentVolumeSource.CSI == nil {
|
|
||||||
pvSpec.PersistentVolumeSource.CSI = nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func volumeModeInUse(oldPVSpec *api.PersistentVolumeSpec) bool {
|
func volumeModeInUse(oldPVSpec *api.PersistentVolumeSpec) bool {
|
||||||
|
|
|
@ -28,12 +28,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestDropDisabledFields(t *testing.T) {
|
func TestDropDisabledFields(t *testing.T) {
|
||||||
specWithCSI := func() *api.PersistentVolumeSpec {
|
|
||||||
return &api.PersistentVolumeSpec{PersistentVolumeSource: api.PersistentVolumeSource{CSI: &api.CSIPersistentVolumeSource{}}}
|
|
||||||
}
|
|
||||||
specWithoutCSI := func() *api.PersistentVolumeSpec {
|
|
||||||
return &api.PersistentVolumeSpec{PersistentVolumeSource: api.PersistentVolumeSource{CSI: nil}}
|
|
||||||
}
|
|
||||||
specWithMode := func(mode *api.PersistentVolumeMode) *api.PersistentVolumeSpec {
|
specWithMode := func(mode *api.PersistentVolumeMode) *api.PersistentVolumeSpec {
|
||||||
return &api.PersistentVolumeSpec{VolumeMode: mode}
|
return &api.PersistentVolumeSpec{VolumeMode: mode}
|
||||||
}
|
}
|
||||||
|
@ -45,53 +39,8 @@ func TestDropDisabledFields(t *testing.T) {
|
||||||
newSpec *api.PersistentVolumeSpec
|
newSpec *api.PersistentVolumeSpec
|
||||||
expectOldSpec *api.PersistentVolumeSpec
|
expectOldSpec *api.PersistentVolumeSpec
|
||||||
expectNewSpec *api.PersistentVolumeSpec
|
expectNewSpec *api.PersistentVolumeSpec
|
||||||
csiEnabled bool
|
|
||||||
blockEnabled bool
|
blockEnabled bool
|
||||||
}{
|
}{
|
||||||
"disabled csi clears new": {
|
|
||||||
csiEnabled: false,
|
|
||||||
newSpec: specWithCSI(),
|
|
||||||
expectNewSpec: specWithoutCSI(),
|
|
||||||
oldSpec: nil,
|
|
||||||
expectOldSpec: nil,
|
|
||||||
},
|
|
||||||
"disabled csi clears update when old pv did not use csi": {
|
|
||||||
csiEnabled: false,
|
|
||||||
newSpec: specWithCSI(),
|
|
||||||
expectNewSpec: specWithoutCSI(),
|
|
||||||
oldSpec: specWithoutCSI(),
|
|
||||||
expectOldSpec: specWithoutCSI(),
|
|
||||||
},
|
|
||||||
"disabled csi preserves update when old pv did use csi": {
|
|
||||||
csiEnabled: false,
|
|
||||||
newSpec: specWithCSI(),
|
|
||||||
expectNewSpec: specWithCSI(),
|
|
||||||
oldSpec: specWithCSI(),
|
|
||||||
expectOldSpec: specWithCSI(),
|
|
||||||
},
|
|
||||||
|
|
||||||
"enabled csi preserves new": {
|
|
||||||
csiEnabled: true,
|
|
||||||
newSpec: specWithCSI(),
|
|
||||||
expectNewSpec: specWithCSI(),
|
|
||||||
oldSpec: nil,
|
|
||||||
expectOldSpec: nil,
|
|
||||||
},
|
|
||||||
"enabled csi preserves update when old pv did not use csi": {
|
|
||||||
csiEnabled: true,
|
|
||||||
newSpec: specWithCSI(),
|
|
||||||
expectNewSpec: specWithCSI(),
|
|
||||||
oldSpec: specWithoutCSI(),
|
|
||||||
expectOldSpec: specWithoutCSI(),
|
|
||||||
},
|
|
||||||
"enabled csi preserves update when old pv did use csi": {
|
|
||||||
csiEnabled: true,
|
|
||||||
newSpec: specWithCSI(),
|
|
||||||
expectNewSpec: specWithCSI(),
|
|
||||||
oldSpec: specWithCSI(),
|
|
||||||
expectOldSpec: specWithCSI(),
|
|
||||||
},
|
|
||||||
|
|
||||||
"disabled block clears new": {
|
"disabled block clears new": {
|
||||||
blockEnabled: false,
|
blockEnabled: false,
|
||||||
newSpec: specWithMode(&modeBlock),
|
newSpec: specWithMode(&modeBlock),
|
||||||
|
@ -139,7 +88,6 @@ func TestDropDisabledFields(t *testing.T) {
|
||||||
|
|
||||||
for name, tc := range tests {
|
for name, tc := range tests {
|
||||||
t.Run(name, func(t *testing.T) {
|
t.Run(name, func(t *testing.T) {
|
||||||
defer utilfeaturetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSIPersistentVolume, tc.csiEnabled)()
|
|
||||||
defer utilfeaturetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.BlockVolume, tc.blockEnabled)()
|
defer utilfeaturetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.BlockVolume, tc.blockEnabled)()
|
||||||
|
|
||||||
DropDisabledFields(tc.newSpec, tc.oldSpec)
|
DropDisabledFields(tc.newSpec, tc.oldSpec)
|
||||||
|
|
|
@ -449,7 +449,7 @@ var defaultKubernetesFeatureGates = map[utilfeature.Feature]utilfeature.FeatureS
|
||||||
ServiceNodeExclusion: {Default: false, PreRelease: utilfeature.Alpha},
|
ServiceNodeExclusion: {Default: false, PreRelease: utilfeature.Alpha},
|
||||||
MountContainers: {Default: false, PreRelease: utilfeature.Alpha},
|
MountContainers: {Default: false, PreRelease: utilfeature.Alpha},
|
||||||
VolumeScheduling: {Default: true, PreRelease: utilfeature.GA, LockToDefault: true}, // remove in 1.16
|
VolumeScheduling: {Default: true, PreRelease: utilfeature.GA, LockToDefault: true}, // remove in 1.16
|
||||||
CSIPersistentVolume: {Default: true, PreRelease: utilfeature.GA},
|
CSIPersistentVolume: {Default: true, PreRelease: utilfeature.GA, LockToDefault: true}, // remove in 1.16
|
||||||
CSIDriverRegistry: {Default: true, PreRelease: utilfeature.Beta},
|
CSIDriverRegistry: {Default: true, PreRelease: utilfeature.Beta},
|
||||||
CSINodeInfo: {Default: true, PreRelease: utilfeature.Beta},
|
CSINodeInfo: {Default: true, PreRelease: utilfeature.Beta},
|
||||||
CustomPodDNS: {Default: true, PreRelease: utilfeature.GA, LockToDefault: true}, // remove in 1.16
|
CustomPodDNS: {Default: true, PreRelease: utilfeature.GA, LockToDefault: true}, // remove in 1.16
|
||||||
|
@ -474,7 +474,7 @@ var defaultKubernetesFeatureGates = map[utilfeature.Feature]utilfeature.FeatureS
|
||||||
BalanceAttachedNodeVolumes: {Default: false, PreRelease: utilfeature.Alpha},
|
BalanceAttachedNodeVolumes: {Default: false, PreRelease: utilfeature.Alpha},
|
||||||
PodReadinessGates: {Default: true, PreRelease: utilfeature.Beta},
|
PodReadinessGates: {Default: true, PreRelease: utilfeature.Beta},
|
||||||
VolumeSubpathEnvExpansion: {Default: false, PreRelease: utilfeature.Alpha},
|
VolumeSubpathEnvExpansion: {Default: false, PreRelease: utilfeature.Alpha},
|
||||||
KubeletPluginsWatcher: {Default: true, PreRelease: utilfeature.GA},
|
KubeletPluginsWatcher: {Default: true, PreRelease: utilfeature.GA, LockToDefault: true}, // remove in 1.16
|
||||||
ResourceQuotaScopeSelectors: {Default: true, PreRelease: utilfeature.Beta},
|
ResourceQuotaScopeSelectors: {Default: true, PreRelease: utilfeature.Beta},
|
||||||
CSIBlockVolume: {Default: false, PreRelease: utilfeature.Alpha},
|
CSIBlockVolume: {Default: false, PreRelease: utilfeature.Alpha},
|
||||||
RuntimeClass: {Default: false, PreRelease: utilfeature.Alpha},
|
RuntimeClass: {Default: false, PreRelease: utilfeature.Alpha},
|
||||||
|
|
|
@ -56,9 +56,6 @@ func TestNodeAuthorizer(t *testing.T) {
|
||||||
tokenNode2 = "node2-token"
|
tokenNode2 = "node2-token"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Enabled CSIPersistentVolume feature at startup so volumeattachments get watched
|
|
||||||
defer utilfeaturetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSIPersistentVolume, true)()
|
|
||||||
|
|
||||||
// Enable DynamicKubeletConfig feature so that Node.Spec.ConfigSource can be set
|
// Enable DynamicKubeletConfig feature so that Node.Spec.ConfigSource can be set
|
||||||
defer utilfeaturetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.DynamicKubeletConfig, true)()
|
defer utilfeaturetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.DynamicKubeletConfig, true)()
|
||||||
|
|
||||||
|
@ -576,12 +573,7 @@ func TestNodeAuthorizer(t *testing.T) {
|
||||||
expectAllowed(t, updatePVCCapacity(node2Client))
|
expectAllowed(t, updatePVCCapacity(node2Client))
|
||||||
expectForbidden(t, updatePVCPhase(node2Client))
|
expectForbidden(t, updatePVCPhase(node2Client))
|
||||||
|
|
||||||
// Disabled CSIPersistentVolume feature
|
|
||||||
defer utilfeaturetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSIPersistentVolume, false)()
|
|
||||||
expectForbidden(t, getVolumeAttachment(node1ClientExternal))
|
|
||||||
expectForbidden(t, getVolumeAttachment(node2ClientExternal))
|
|
||||||
// Enabled CSIPersistentVolume feature
|
// Enabled CSIPersistentVolume feature
|
||||||
defer utilfeaturetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSIPersistentVolume, true)()
|
|
||||||
expectForbidden(t, getVolumeAttachment(node1ClientExternal))
|
expectForbidden(t, getVolumeAttachment(node1ClientExternal))
|
||||||
expectAllowed(t, getVolumeAttachment(node2ClientExternal))
|
expectAllowed(t, getVolumeAttachment(node2ClientExternal))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue