Skip to content

Commit d145bf0

Browse files
authored
Merge pull request kubernetes#125138 from AkihiroSuda/fix-125137
kubelet: fix `Turning off swap in unprivileged tmpfs mounts unsupported`
2 parents e328c8f + b3175b8 commit d145bf0

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pkg/kubelet/util/swap/swap_util.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626

2727
"k8s.io/apimachinery/pkg/util/version"
2828
"k8s.io/klog/v2"
29+
"k8s.io/kubernetes/pkg/kubelet/userns/inuserns"
2930
utilkernel "k8s.io/kubernetes/pkg/util/kernel"
3031
"k8s.io/mount-utils"
3132
)
@@ -46,6 +47,14 @@ func IsTmpfsNoswapOptionSupported(mounter mount.Interface, mountPath string) boo
4647
return false
4748
}
4849

50+
if inuserns.RunningInUserNS() {
51+
// Turning off swap in unprivileged tmpfs mounts unsupported
52+
// https://github.com/torvalds/linux/blob/v6.8/mm/shmem.c#L4004-L4011
53+
// https://github.com/kubernetes/kubernetes/issues/125137
54+
klog.InfoS("Running under a user namespace - tmpfs noswap is not supported")
55+
return false
56+
}
57+
4958
kernelVersion, err := utilkernel.GetVersion()
5059
if err != nil {
5160
klog.ErrorS(err, "cannot determine kernel version, unable to determine is tmpfs noswap is supported")

0 commit comments

Comments
 (0)