remove ExpandInUsePersistentVolume feature gate

This commit is contained in:
Hemant Kumar 2022-03-24 11:19:42 -04:00
parent 966e1b6dd0
commit cdfb841a52
5 changed files with 22 additions and 57 deletions

View File

@ -26,9 +26,7 @@ import (
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/types"
utilfeature "k8s.io/apiserver/pkg/util/feature"
"k8s.io/klog/v2"
"k8s.io/kubernetes/pkg/features"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util/operationexecutor"
@ -714,8 +712,7 @@ func (asw *actualStateOfWorld) PodExistsInVolume(
return true, volumeObj.devicePath, newRemountRequiredError(volumeObj.volumeName, podObj.podName)
}
if podObj.fsResizeRequired &&
!volumeObj.volumeInUseErrorForExpansion &&
utilfeature.DefaultFeatureGate.Enabled(features.ExpandInUsePersistentVolumes) {
!volumeObj.volumeInUseErrorForExpansion {
return true, volumeObj.devicePath, newFsResizeRequiredError(volumeObj.volumeName, podObj.podName)
}
}

View File

@ -34,10 +34,8 @@ import (
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/wait"
utilfeature "k8s.io/apiserver/pkg/util/feature"
clientset "k8s.io/client-go/kubernetes"
"k8s.io/component-helpers/storage/ephemeral"
"k8s.io/kubernetes/pkg/features"
"k8s.io/kubernetes/pkg/kubelet/config"
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
"k8s.io/kubernetes/pkg/kubelet/pod"
@ -188,15 +186,13 @@ func (dswp *desiredStateOfWorldPopulator) populatorLoop() {
func (dswp *desiredStateOfWorldPopulator) findAndAddNewPods() {
// Map unique pod name to outer volume name to MountedVolume.
mountedVolumesForPod := make(map[volumetypes.UniquePodName]map[string]cache.MountedVolume)
if utilfeature.DefaultFeatureGate.Enabled(features.ExpandInUsePersistentVolumes) {
for _, mountedVolume := range dswp.actualStateOfWorld.GetMountedVolumes() {
mountedVolumes, exist := mountedVolumesForPod[mountedVolume.PodName]
if !exist {
mountedVolumes = make(map[string]cache.MountedVolume)
mountedVolumesForPod[mountedVolume.PodName] = mountedVolumes
}
mountedVolumes[mountedVolume.OuterVolumeSpecName] = mountedVolume
for _, mountedVolume := range dswp.actualStateOfWorld.GetMountedVolumes() {
mountedVolumes, exist := mountedVolumesForPod[mountedVolume.PodName]
if !exist {
mountedVolumes = make(map[string]cache.MountedVolume)
mountedVolumesForPod[mountedVolume.PodName] = mountedVolumes
}
mountedVolumes[mountedVolume.OuterVolumeSpecName] = mountedVolume
}
processedVolumesForFSResize := sets.NewString()
@ -288,7 +284,6 @@ func (dswp *desiredStateOfWorldPopulator) processPodVolumes(
allVolumesAdded := true
mounts, devices := util.GetPodVolumeNames(pod)
expandInUsePV := utilfeature.DefaultFeatureGate.Enabled(features.ExpandInUsePersistentVolumes)
// Process volume spec for each volume defined in pod
for _, podVolume := range pod.Spec.Volumes {
if !mounts.Has(podVolume.Name) && !devices.Has(podVolume.Name) {
@ -319,10 +314,9 @@ func (dswp *desiredStateOfWorldPopulator) processPodVolumes(
// sync reconstructed volume
dswp.actualStateOfWorld.SyncReconstructedVolume(uniqueVolumeName, uniquePodName, podVolume.Name)
if expandInUsePV {
dswp.checkVolumeFSResize(pod, podVolume, pvc, volumeSpec,
uniquePodName, mountedVolumesForPod, processedVolumesForFSResize)
}
dswp.checkVolumeFSResize(pod, podVolume, pvc, volumeSpec,
uniquePodName, mountedVolumesForPod, processedVolumesForFSResize)
}
// some of the volume additions may have failed, should not mark this pod as fully processed

View File

@ -31,9 +31,7 @@ import (
utilfeature "k8s.io/apiserver/pkg/util/feature"
"k8s.io/client-go/kubernetes/fake"
core "k8s.io/client-go/testing"
featuregatetesting "k8s.io/component-base/featuregate/testing"
csitrans "k8s.io/csi-translation-lib"
"k8s.io/kubernetes/pkg/features"
"k8s.io/kubernetes/pkg/kubelet/configmap"
containertest "k8s.io/kubernetes/pkg/kubelet/container/testing"
kubepod "k8s.io/kubernetes/pkg/kubelet/pod"
@ -911,11 +909,10 @@ func TestCheckVolumeFSResize(t *testing.T) {
}
testcases := []struct {
resize func(*testing.T, *v1.PersistentVolume, *v1.PersistentVolumeClaim, *desiredStateOfWorldPopulator)
verify func(*testing.T, []v1.UniqueVolumeName, v1.UniqueVolumeName)
enableResize bool
readOnlyVol bool
volumeMode v1.PersistentVolumeMode
resize func(*testing.T, *v1.PersistentVolume, *v1.PersistentVolumeClaim, *desiredStateOfWorldPopulator)
verify func(*testing.T, []v1.UniqueVolumeName, v1.UniqueVolumeName)
readOnlyVol bool
volumeMode v1.PersistentVolumeMode
}{
{
// No resize request for volume, volumes in ASW shouldn't be marked as fsResizeRequired
@ -926,22 +923,9 @@ func TestCheckVolumeFSResize(t *testing.T) {
t.Errorf("No resize request for any volumes, but found resize required volumes in ASW: %v", vols)
}
},
enableResize: true,
volumeMode: v1.PersistentVolumeFilesystem,
},
{
// Disable the feature gate, so volume shouldn't be marked as fsResizeRequired
resize: func(_ *testing.T, pv *v1.PersistentVolume, pvc *v1.PersistentVolumeClaim, _ *desiredStateOfWorldPopulator) {
setCapacity(pv, pvc, 2)
},
verify: func(t *testing.T, vols []v1.UniqueVolumeName, _ v1.UniqueVolumeName) {
if len(vols) > 0 {
t.Errorf("Feature gate disabled, but found resize required volumes in ASW: %v", vols)
}
},
enableResize: false,
volumeMode: v1.PersistentVolumeFilesystem,
volumeMode: v1.PersistentVolumeFilesystem,
},
{
// Make volume used as ReadOnly, so volume shouldn't be marked as fsResizeRequired
resize: func(_ *testing.T, pv *v1.PersistentVolume, pvc *v1.PersistentVolumeClaim, _ *desiredStateOfWorldPopulator) {
@ -952,9 +936,8 @@ func TestCheckVolumeFSResize(t *testing.T) {
t.Errorf("volume mounted as ReadOnly, but found resize required volumes in ASW: %v", vols)
}
},
readOnlyVol: true,
enableResize: true,
volumeMode: v1.PersistentVolumeFilesystem,
readOnlyVol: true,
volumeMode: v1.PersistentVolumeFilesystem,
},
{
// Clear ASW, so volume shouldn't be marked as fsResizeRequired because they are not mounted
@ -967,8 +950,7 @@ func TestCheckVolumeFSResize(t *testing.T) {
t.Errorf("volume hasn't been mounted, but found resize required volumes in ASW: %v", vols)
}
},
enableResize: true,
volumeMode: v1.PersistentVolumeFilesystem,
volumeMode: v1.PersistentVolumeFilesystem,
},
{
// volume in ASW should be marked as fsResizeRequired
@ -986,8 +968,7 @@ func TestCheckVolumeFSResize(t *testing.T) {
t.Fatalf("Mark wrong volume as fsResizeRequired: %s", vols[0])
}
},
enableResize: true,
volumeMode: v1.PersistentVolumeFilesystem,
volumeMode: v1.PersistentVolumeFilesystem,
},
{
// volume in ASW should be marked as fsResizeRequired
@ -1005,8 +986,7 @@ func TestCheckVolumeFSResize(t *testing.T) {
t.Fatalf("Mark wrong volume as fsResizeRequired: %s", vols[0])
}
},
enableResize: true,
volumeMode: v1.PersistentVolumeBlock,
volumeMode: v1.PersistentVolumeBlock,
},
}
@ -1071,8 +1051,6 @@ func TestCheckVolumeFSResize(t *testing.T) {
reconcileASW(fakeASW, fakeDSW, t)
func() {
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.ExpandInUsePersistentVolumes, tc.enableResize)()
tc.resize(t, pv, pvc, dswp)
resizeRequiredVolumes := reprocess(dswp, uniquePodName, fakeDSW, fakeASW)

View File

@ -31,13 +31,10 @@ import (
"k8s.io/apimachinery/pkg/runtime"
k8stypes "k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/wait"
utilfeature "k8s.io/apiserver/pkg/util/feature"
"k8s.io/client-go/kubernetes/fake"
core "k8s.io/client-go/testing"
"k8s.io/client-go/tools/record"
featuregatetesting "k8s.io/component-base/featuregate/testing"
"k8s.io/klog/v2"
"k8s.io/kubernetes/pkg/features"
"k8s.io/kubernetes/pkg/kubelet/volumemanager/cache"
"k8s.io/kubernetes/pkg/volume"
volumetesting "k8s.io/kubernetes/pkg/volume/testing"
@ -1118,7 +1115,6 @@ func Test_GenerateUnmapDeviceFunc_Plugin_Not_Found(t *testing.T) {
// Mark volume as fsResizeRequired in ASW.
// Verifies volume's fsResizeRequired flag is cleared later.
func Test_Run_Positive_VolumeFSResizeControllerAttachEnabled(t *testing.T) {
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.ExpandInUsePersistentVolumes, true)()
blockMode := v1.PersistentVolumeBlock
fsMode := v1.PersistentVolumeFilesystem

View File

@ -39,7 +39,7 @@ import (
imageutils "k8s.io/kubernetes/test/utils/image"
)
var _ = utils.SIGDescribe("Mounted flexvolume volume expand [Slow] [Feature:ExpandInUsePersistentVolumes]", func() {
var _ = utils.SIGDescribe("Mounted flexvolume volume expand [Slow]", func() {
var (
c clientset.Interface
ns string