mirror of
				https://github.com/k3s-io/kubernetes.git
				synced 2025-10-31 13:50:01 +00:00 
			
		
		
		
	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 <akihiro.suda.cz@hco.ntt.co.jp>
This commit is contained in:
		| @@ -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) | ||||
| 			} | ||||
| 		} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user