From dbe015513971b69b2f69c02de1bb5960fe230b51 Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Tue, 21 Aug 2018 16:45:04 +0900 Subject: [PATCH] kubelet/cm: ignore sysctl error when running in userns Errors during setting the following sysctl values are ignored: - vm.overcommit_memory - vm.panic_on_oom - kernel.panic - kernel.panic_on_oops - kernel.keys.root_maxkeys - kernel.keys.root_maxbytes Signed-off-by: Akihiro Suda --- pkg/kubelet/cm/container_manager_linux.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/kubelet/cm/container_manager_linux.go b/pkg/kubelet/cm/container_manager_linux.go index d98162ec8a8..03f5aa36503 100644 --- a/pkg/kubelet/cm/container_manager_linux.go +++ b/pkg/kubelet/cm/container_manager_linux.go @@ -39,6 +39,7 @@ import ( utilpath "k8s.io/utils/path" libcontainerdevices "github.com/opencontainers/runc/libcontainer/devices" + libcontaineruserns "github.com/opencontainers/runc/libcontainer/userns" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" utilerrors "k8s.io/apimachinery/pkg/util/errors" @@ -455,6 +456,13 @@ func setupKernelTunables(option KernelTunableBehavior) error { klog.V(2).InfoS("Updating kernel flag", "flag", flag, "expectedValue", expectedValue, "actualValue", val) err = sysctl.SetSysctl(flag, expectedValue) if err != nil { + if libcontaineruserns.RunningInUserNS() { + if utilfeature.DefaultFeatureGate.Enabled(kubefeatures.KubeletInUserNamespace) { + klog.V(2).InfoS("Updating kernel flag failed (running in UserNS, ignoring)", "flag", flag, "err", err) + continue + } + klog.ErrorS(err, "Updating kernel flag failed (Hint: enable KubeletInUserNamespace feature flag to ignore the error)", "flag", flag) + } errList = append(errList, err) } }