Merge pull request #125138 from AkihiroSuda/fix-125137

kubelet: fix `Turning off swap in unprivileged tmpfs mounts unsupported`
This commit is contained in:
Kubernetes Prow Robot 2024-06-09 19:43:11 -07:00 committed by GitHub
commit d145bf0907
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -26,6 +26,7 @@ import (
"k8s.io/apimachinery/pkg/util/version"
"k8s.io/klog/v2"
"k8s.io/kubernetes/pkg/kubelet/userns/inuserns"
utilkernel "k8s.io/kubernetes/pkg/util/kernel"
"k8s.io/mount-utils"
)
@ -46,6 +47,14 @@ func IsTmpfsNoswapOptionSupported(mounter mount.Interface, mountPath string) boo
return false
}
if inuserns.RunningInUserNS() {
// Turning off swap in unprivileged tmpfs mounts unsupported
// https://github.com/torvalds/linux/blob/v6.8/mm/shmem.c#L4004-L4011
// https://github.com/kubernetes/kubernetes/issues/125137
klog.InfoS("Running under a user namespace - tmpfs noswap is not supported")
return false
}
kernelVersion, err := utilkernel.GetVersion()
if err != nil {
klog.ErrorS(err, "cannot determine kernel version, unable to determine is tmpfs noswap is supported")