mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-20 10:20:51 +00:00
Split volume reconstruction refactoring from SELinuxMountReadWriteOncePod
Add a new feature gate NewVolumeManagerReconstruction and add the new volume reconstruction done in 1.26 under that feature gate.
This commit is contained in:
parent
f21c603417
commit
cca3d557e6
@ -562,6 +562,13 @@ const (
|
|||||||
// Enables NetworkPolicy status subresource
|
// Enables NetworkPolicy status subresource
|
||||||
NetworkPolicyStatus featuregate.Feature = "NetworkPolicyStatus"
|
NetworkPolicyStatus featuregate.Feature = "NetworkPolicyStatus"
|
||||||
|
|
||||||
|
// owner: @jsafrane
|
||||||
|
// kep: https://kep.k8s.io/3756
|
||||||
|
// alpha: v1.25 (as part of SELinuxMountReadWriteOncePod)
|
||||||
|
// beta: v1.27
|
||||||
|
// Robust VolumeManager reconstruction after kubelet restart.
|
||||||
|
NewVolumeManagerReconstruction featuregate.Feature = "NewVolumeManagerReconstruction"
|
||||||
|
|
||||||
// owner: @xing-yang @sonasingh46
|
// owner: @xing-yang @sonasingh46
|
||||||
// kep: https://kep.k8s.io/2268
|
// kep: https://kep.k8s.io/2268
|
||||||
// alpha: v1.24
|
// alpha: v1.24
|
||||||
@ -984,6 +991,8 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS
|
|||||||
|
|
||||||
NetworkPolicyStatus: {Default: false, PreRelease: featuregate.Alpha},
|
NetworkPolicyStatus: {Default: false, PreRelease: featuregate.Alpha},
|
||||||
|
|
||||||
|
NewVolumeManagerReconstruction: {Default: true, PreRelease: featuregate.Beta},
|
||||||
|
|
||||||
NodeOutOfServiceVolumeDetach: {Default: true, PreRelease: featuregate.Beta},
|
NodeOutOfServiceVolumeDetach: {Default: true, PreRelease: featuregate.Beta},
|
||||||
|
|
||||||
NodeSwap: {Default: false, PreRelease: featuregate.Alpha},
|
NodeSwap: {Default: false, PreRelease: featuregate.Alpha},
|
||||||
|
@ -323,7 +323,7 @@ func (dswp *desiredStateOfWorldPopulator) processPodVolumes(
|
|||||||
} else {
|
} else {
|
||||||
klog.V(4).InfoS("Added volume to desired state", "pod", klog.KObj(pod), "volumeName", podVolume.Name, "volumeSpecName", volumeSpec.Name())
|
klog.V(4).InfoS("Added volume to desired state", "pod", klog.KObj(pod), "volumeName", podVolume.Name, "volumeSpecName", volumeSpec.Name())
|
||||||
}
|
}
|
||||||
if !utilfeature.DefaultFeatureGate.Enabled(features.SELinuxMountReadWriteOncePod) {
|
if !utilfeature.DefaultFeatureGate.Enabled(features.NewVolumeManagerReconstruction) {
|
||||||
// sync reconstructed volume. This is necessary only when the old-style reconstruction is still used.
|
// sync reconstructed volume. This is necessary only when the old-style reconstruction is still used.
|
||||||
// With reconstruct_new.go, AWS.MarkVolumeAsMounted will update the outer spec name of previously
|
// With reconstruct_new.go, AWS.MarkVolumeAsMounted will update the outer spec name of previously
|
||||||
// uncertain volumes.
|
// uncertain volumes.
|
||||||
|
@ -89,8 +89,7 @@ func prepareDswpWithVolume(t *testing.T) (*desiredStateOfWorldPopulator, kubepod
|
|||||||
|
|
||||||
func TestFindAndAddNewPods_WithRescontructedVolume(t *testing.T) {
|
func TestFindAndAddNewPods_WithRescontructedVolume(t *testing.T) {
|
||||||
// Outer volume spec replacement is needed only when the old volume reconstruction is used
|
// Outer volume spec replacement is needed only when the old volume reconstruction is used
|
||||||
// (i.e. with SELinuxMountReadWriteOncePod disabled)
|
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.NewVolumeManagerReconstruction, false)()
|
||||||
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.SELinuxMountReadWriteOncePod, false)()
|
|
||||||
// create dswp
|
// create dswp
|
||||||
dswp, fakePodManager, _ := prepareDswpWithVolume(t)
|
dswp, fakePodManager, _ := prepareDswpWithVolume(t)
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ type reconciler struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (rc *reconciler) Run(stopCh <-chan struct{}) {
|
func (rc *reconciler) Run(stopCh <-chan struct{}) {
|
||||||
if utilfeature.DefaultFeatureGate.Enabled(features.SELinuxMountReadWriteOncePod) {
|
if utilfeature.DefaultFeatureGate.Enabled(features.NewVolumeManagerReconstruction) {
|
||||||
rc.runNew(stopCh)
|
rc.runNew(stopCh)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -21,9 +21,9 @@ import (
|
|||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: move to reconciler.go and remove old code there when SELinuxMountReadWriteOncePod is GA
|
// TODO: move to reconciler.go and remove old code there when NewVolumeManagerReconstruction is GA
|
||||||
|
|
||||||
// TODO: Replace Run() when SELinuxMountReadWriteOncePod is GA
|
// TODO: Replace Run() when NewVolumeManagerReconstruction is GA
|
||||||
func (rc *reconciler) runNew(stopCh <-chan struct{}) {
|
func (rc *reconciler) runNew(stopCh <-chan struct{}) {
|
||||||
rc.reconstructVolumes()
|
rc.reconstructVolumes()
|
||||||
klog.InfoS("Reconciler: start to sync state")
|
klog.InfoS("Reconciler: start to sync state")
|
||||||
|
@ -34,7 +34,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestReconstructVolumes(t *testing.T) {
|
func TestReconstructVolumes(t *testing.T) {
|
||||||
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.SELinuxMountReadWriteOncePod, true)()
|
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.NewVolumeManagerReconstruction, true)()
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
@ -146,7 +146,7 @@ func TestReconstructVolumes(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCleanOrphanVolumes(t *testing.T) {
|
func TestCleanOrphanVolumes(t *testing.T) {
|
||||||
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.SELinuxMountReadWriteOncePod, true)()
|
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.NewVolumeManagerReconstruction, true)()
|
||||||
|
|
||||||
type podInfo struct {
|
type podInfo struct {
|
||||||
podName string
|
podName string
|
||||||
@ -261,7 +261,7 @@ func TestReconstructVolumesMount(t *testing.T) {
|
|||||||
// Since the volume is reconstructed, it must be marked as uncertain
|
// Since the volume is reconstructed, it must be marked as uncertain
|
||||||
// even after a final SetUp error, see https://github.com/kubernetes/kubernetes/issues/96635
|
// even after a final SetUp error, see https://github.com/kubernetes/kubernetes/issues/96635
|
||||||
// and https://github.com/kubernetes/kubernetes/pull/110670.
|
// and https://github.com/kubernetes/kubernetes/pull/110670.
|
||||||
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.SELinuxMountReadWriteOncePod, true)()
|
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.NewVolumeManagerReconstruction, true)()
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
|
Loading…
Reference in New Issue
Block a user