mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
Merge pull request #68230 from bertinatto/remove_mount_propagation_gate
Remove mount propagation feature gate
This commit is contained in:
commit
08351b6d6d
@ -248,13 +248,6 @@ func DropDisabledAlphaFields(podSpec *api.PodSpec) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := range podSpec.Containers {
|
|
||||||
DropDisabledVolumeMountsAlphaFields(podSpec.Containers[i].VolumeMounts)
|
|
||||||
}
|
|
||||||
for i := range podSpec.InitContainers {
|
|
||||||
DropDisabledVolumeMountsAlphaFields(podSpec.InitContainers[i].VolumeMounts)
|
|
||||||
}
|
|
||||||
|
|
||||||
DropDisabledVolumeDevicesAlphaFields(podSpec)
|
DropDisabledVolumeDevicesAlphaFields(podSpec)
|
||||||
|
|
||||||
DropDisabledRunAsGroupField(podSpec)
|
DropDisabledRunAsGroupField(podSpec)
|
||||||
@ -304,16 +297,6 @@ func DropDisabledProcMountField(podSpec *api.PodSpec) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DropDisabledVolumeMountsAlphaFields removes disabled fields from []VolumeMount.
|
|
||||||
// This should be called from PrepareForCreate/PrepareForUpdate for all resources containing a VolumeMount
|
|
||||||
func DropDisabledVolumeMountsAlphaFields(volumeMounts []api.VolumeMount) {
|
|
||||||
if !utilfeature.DefaultFeatureGate.Enabled(features.MountPropagation) {
|
|
||||||
for i := range volumeMounts {
|
|
||||||
volumeMounts[i].MountPropagation = nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// DropDisabledVolumeDevicesAlphaFields removes disabled fields from []VolumeDevice.
|
// DropDisabledVolumeDevicesAlphaFields removes disabled fields from []VolumeDevice.
|
||||||
// This should be called from PrepareForCreate/PrepareForUpdate for all resources containing a VolumeDevice
|
// This should be called from PrepareForCreate/PrepareForUpdate for all resources containing a VolumeDevice
|
||||||
func DropDisabledVolumeDevicesAlphaFields(podSpec *api.PodSpec) {
|
func DropDisabledVolumeDevicesAlphaFields(podSpec *api.PodSpec) {
|
||||||
|
@ -1115,10 +1115,6 @@ func validateMountPropagation(mountPropagation *core.MountPropagationMode, conta
|
|||||||
if mountPropagation == nil {
|
if mountPropagation == nil {
|
||||||
return allErrs
|
return allErrs
|
||||||
}
|
}
|
||||||
if !utilfeature.DefaultFeatureGate.Enabled(features.MountPropagation) {
|
|
||||||
allErrs = append(allErrs, field.Forbidden(fldPath, "mount propagation is disabled by feature-gate"))
|
|
||||||
return allErrs
|
|
||||||
}
|
|
||||||
|
|
||||||
supportedMountPropagations := sets.NewString(string(core.MountPropagationBidirectional), string(core.MountPropagationHostToContainer), string(core.MountPropagationNone))
|
supportedMountPropagations := sets.NewString(string(core.MountPropagationBidirectional), string(core.MountPropagationHostToContainer), string(core.MountPropagationNone))
|
||||||
if !supportedMountPropagations.Has(string(*mountPropagation)) {
|
if !supportedMountPropagations.Has(string(*mountPropagation)) {
|
||||||
|
@ -5038,26 +5038,6 @@ func TestValidateMountPropagation(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable MountPropagation for this test
|
|
||||||
priorityEnabled := utilfeature.DefaultFeatureGate.Enabled("MountPropagation")
|
|
||||||
defer func() {
|
|
||||||
var err error
|
|
||||||
// restoring the old value
|
|
||||||
if priorityEnabled {
|
|
||||||
err = utilfeature.DefaultFeatureGate.Set("MountPropagation=true")
|
|
||||||
} else {
|
|
||||||
err = utilfeature.DefaultFeatureGate.Set("MountPropagation=false")
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("Failed to restore feature gate for MountPropagation: %v", err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
err := utilfeature.DefaultFeatureGate.Set("MountPropagation=true")
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("Failed to enable feature gate for MountPropagation: %v", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
volumes := []core.Volume{
|
volumes := []core.Volume{
|
||||||
{Name: "foo", VolumeSource: core.VolumeSource{HostPath: &core.HostPathVolumeSource{Path: "/foo/baz", Type: newHostPathType(string(core.HostPathUnset))}}},
|
{Name: "foo", VolumeSource: core.VolumeSource{HostPath: &core.HostPathVolumeSource{Path: "/foo/baz", Type: newHostPathType(string(core.HostPathUnset))}}},
|
||||||
}
|
}
|
||||||
|
@ -140,6 +140,7 @@ const (
|
|||||||
// owner: @jsafrane
|
// owner: @jsafrane
|
||||||
// GA: v1.12
|
// GA: v1.12
|
||||||
//
|
//
|
||||||
|
// Note: This feature gate is unconditionally enabled in v1.13 and will be removed in v1.14.
|
||||||
// Enable mount propagation of volumes.
|
// Enable mount propagation of volumes.
|
||||||
MountPropagation utilfeature.Feature = "MountPropagation"
|
MountPropagation utilfeature.Feature = "MountPropagation"
|
||||||
|
|
||||||
|
@ -32,7 +32,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
|
|
||||||
cadvisorapi "github.com/google/cadvisor/info/v1"
|
cadvisorapi "github.com/google/cadvisor/info/v1"
|
||||||
cadvisorapiv2 "github.com/google/cadvisor/info/v2"
|
cadvisorapiv2 "github.com/google/cadvisor/info/v2"
|
||||||
"k8s.io/api/core/v1"
|
"k8s.io/api/core/v1"
|
||||||
@ -777,7 +776,7 @@ func NewMainKubelet(kubeCfg *kubeletconfiginternal.KubeletConfiguration,
|
|||||||
tokenManager := token.NewManager(kubeDeps.KubeClient)
|
tokenManager := token.NewManager(kubeDeps.KubeClient)
|
||||||
|
|
||||||
if !utilfeature.DefaultFeatureGate.Enabled(features.MountPropagation) {
|
if !utilfeature.DefaultFeatureGate.Enabled(features.MountPropagation) {
|
||||||
glog.Warning("Mount propagation feature gate has been deprecated and will be removed in the next release")
|
return nil, fmt.Errorf("mount propagation feature gate has been deprecated and will be removed in 1.14")
|
||||||
}
|
}
|
||||||
|
|
||||||
klet.volumePluginMgr, err =
|
klet.volumePluginMgr, err =
|
||||||
|
@ -262,10 +262,6 @@ func translateMountPropagation(mountMode *v1.MountPropagationMode) (runtimeapi.M
|
|||||||
return runtimeapi.MountPropagation_PROPAGATION_PRIVATE, nil
|
return runtimeapi.MountPropagation_PROPAGATION_PRIVATE, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if !utilfeature.DefaultFeatureGate.Enabled(features.MountPropagation) {
|
|
||||||
// mount propagation is disabled, use private as in the old versions
|
|
||||||
return runtimeapi.MountPropagation_PROPAGATION_PRIVATE, nil
|
|
||||||
}
|
|
||||||
switch {
|
switch {
|
||||||
case mountMode == nil:
|
case mountMode == nil:
|
||||||
// PRIVATE is the default
|
// PRIVATE is the default
|
||||||
|
@ -23,7 +23,6 @@ import (
|
|||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"k8s.io/api/core/v1"
|
"k8s.io/api/core/v1"
|
||||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
|
||||||
|
|
||||||
_ "k8s.io/kubernetes/pkg/apis/core/install"
|
_ "k8s.io/kubernetes/pkg/apis/core/install"
|
||||||
runtimeapi "k8s.io/kubernetes/pkg/kubelet/apis/cri/runtime/v1alpha2"
|
runtimeapi "k8s.io/kubernetes/pkg/kubelet/apis/cri/runtime/v1alpha2"
|
||||||
@ -247,12 +246,6 @@ func TestMakeMounts(t *testing.T) {
|
|||||||
HostNetwork: true,
|
HostNetwork: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
// test makeMounts with enabled mount propagation
|
|
||||||
err := utilfeature.DefaultFeatureGate.Set("MountPropagation=true")
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("Failed to enable feature gate for MountPropagation: %v", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
mounts, _, err := makeMounts(&pod, "/pod", &tc.container, "fakepodname", "", "", tc.podVolumes, fm, nil)
|
mounts, _, err := makeMounts(&pod, "/pod", &tc.container, "fakepodname", "", "", tc.podVolumes, fm, nil)
|
||||||
|
|
||||||
@ -270,24 +263,6 @@ func TestMakeMounts(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
assert.Equal(t, tc.expectedMounts, mounts, "mounts of container %+v", tc.container)
|
assert.Equal(t, tc.expectedMounts, mounts, "mounts of container %+v", tc.container)
|
||||||
|
|
||||||
// test makeMounts with disabled mount propagation
|
|
||||||
err = utilfeature.DefaultFeatureGate.Set("MountPropagation=false")
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("Failed to enable feature gate for MountPropagation: %v", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
mounts, _, err = makeMounts(&pod, "/pod", &tc.container, "fakepodname", "", "", tc.podVolumes, fm, nil)
|
|
||||||
if !tc.expectErr {
|
|
||||||
expectedPrivateMounts := []kubecontainer.Mount{}
|
|
||||||
for _, mount := range tc.expectedMounts {
|
|
||||||
// all mounts are expected to be private when mount
|
|
||||||
// propagation is disabled
|
|
||||||
mount.Propagation = runtimeapi.MountPropagation_PROPAGATION_PRIVATE
|
|
||||||
expectedPrivateMounts = append(expectedPrivateMounts, mount)
|
|
||||||
}
|
|
||||||
assert.Equal(t, expectedPrivateMounts, mounts, "mounts of container %+v", tc.container)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,6 @@ go_library(
|
|||||||
importpath = "k8s.io/kubernetes/pkg/registry/settings/podpreset",
|
importpath = "k8s.io/kubernetes/pkg/registry/settings/podpreset",
|
||||||
deps = [
|
deps = [
|
||||||
"//pkg/api/legacyscheme:go_default_library",
|
"//pkg/api/legacyscheme:go_default_library",
|
||||||
"//pkg/api/pod:go_default_library",
|
|
||||||
"//pkg/apis/settings:go_default_library",
|
"//pkg/apis/settings:go_default_library",
|
||||||
"//pkg/apis/settings/validation:go_default_library",
|
"//pkg/apis/settings/validation:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||||
|
@ -23,7 +23,6 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/util/validation/field"
|
"k8s.io/apimachinery/pkg/util/validation/field"
|
||||||
"k8s.io/apiserver/pkg/storage/names"
|
"k8s.io/apiserver/pkg/storage/names"
|
||||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||||
"k8s.io/kubernetes/pkg/api/pod"
|
|
||||||
"k8s.io/kubernetes/pkg/apis/settings"
|
"k8s.io/kubernetes/pkg/apis/settings"
|
||||||
"k8s.io/kubernetes/pkg/apis/settings/validation"
|
"k8s.io/kubernetes/pkg/apis/settings/validation"
|
||||||
)
|
)
|
||||||
@ -46,8 +45,6 @@ func (podPresetStrategy) NamespaceScoped() bool {
|
|||||||
func (podPresetStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
|
func (podPresetStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
|
||||||
pip := obj.(*settings.PodPreset)
|
pip := obj.(*settings.PodPreset)
|
||||||
pip.Generation = 1
|
pip.Generation = 1
|
||||||
|
|
||||||
pod.DropDisabledVolumeMountsAlphaFields(pip.Spec.VolumeMounts)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// PrepareForUpdate clears fields that are not allowed to be set by end users on update.
|
// PrepareForUpdate clears fields that are not allowed to be set by end users on update.
|
||||||
@ -55,9 +52,6 @@ func (podPresetStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.
|
|||||||
newPodPreset := obj.(*settings.PodPreset)
|
newPodPreset := obj.(*settings.PodPreset)
|
||||||
oldPodPreset := old.(*settings.PodPreset)
|
oldPodPreset := old.(*settings.PodPreset)
|
||||||
|
|
||||||
pod.DropDisabledVolumeMountsAlphaFields(oldPodPreset.Spec.VolumeMounts)
|
|
||||||
pod.DropDisabledVolumeMountsAlphaFields(newPodPreset.Spec.VolumeMounts)
|
|
||||||
|
|
||||||
// Update is not allowed
|
// Update is not allowed
|
||||||
newPodPreset.Spec = oldPodPreset.Spec
|
newPodPreset.Spec = oldPodPreset.Spec
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user