Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split volume reconstruction refactoring from SELinuxMountReadWriteOncePod #115268

Merged
merged 1 commit into from Mar 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions pkg/features/kube_features.go
Expand Up @@ -562,6 +562,13 @@ const (
// Enables NetworkPolicy status subresource
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
// kep: https://kep.k8s.io/2268
// alpha: v1.24
Expand Down Expand Up @@ -984,6 +991,8 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS

NetworkPolicyStatus: {Default: false, PreRelease: featuregate.Alpha},

NewVolumeManagerReconstruction: {Default: true, PreRelease: featuregate.Beta},

NodeOutOfServiceVolumeDetach: {Default: true, PreRelease: featuregate.Beta},

NodeSwap: {Default: false, PreRelease: featuregate.Alpha},
Expand Down
Expand Up @@ -323,7 +323,7 @@ func (dswp *desiredStateOfWorldPopulator) processPodVolumes(
} else {
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.
// With reconstruct_new.go, AWS.MarkVolumeAsMounted will update the outer spec name of previously
// uncertain volumes.
Expand Down
Expand Up @@ -89,8 +89,7 @@ func prepareDswpWithVolume(t *testing.T) (*desiredStateOfWorldPopulator, kubepod

func TestFindAndAddNewPods_WithRescontructedVolume(t *testing.T) {
// 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.SELinuxMountReadWriteOncePod, false)()
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.NewVolumeManagerReconstruction, false)()
// create dswp
dswp, fakePodManager, _ := prepareDswpWithVolume(t)

Expand Down
2 changes: 1 addition & 1 deletion pkg/kubelet/volumemanager/reconciler/reconciler_common.go
Expand Up @@ -146,7 +146,7 @@ type reconciler struct {
}

func (rc *reconciler) Run(stopCh <-chan struct{}) {
if utilfeature.DefaultFeatureGate.Enabled(features.SELinuxMountReadWriteOncePod) {
if utilfeature.DefaultFeatureGate.Enabled(features.NewVolumeManagerReconstruction) {
rc.runNew(stopCh)
return
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/kubelet/volumemanager/reconciler/reconciler_new.go
Expand Up @@ -21,9 +21,9 @@ import (
"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{}) {
rc.reconstructVolumes()
klog.InfoS("Reconciler: start to sync state")
Expand Down
6 changes: 3 additions & 3 deletions pkg/kubelet/volumemanager/reconciler/reconstruct_new_test.go
Expand Up @@ -34,7 +34,7 @@ import (
)

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 {
name string
Expand Down Expand Up @@ -146,7 +146,7 @@ func TestReconstructVolumes(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 {
podName string
Expand Down Expand Up @@ -261,7 +261,7 @@ func TestReconstructVolumesMount(t *testing.T) {
// 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
// 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 {
name string
Expand Down