Merge pull request #125138 from AkihiroSuda/fix-125137
kubelet: fix `Turning off swap in unprivileged tmpfs mounts unsupported`
This commit is contained in:
		@@ -26,6 +26,7 @@ import (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	"k8s.io/apimachinery/pkg/util/version"
 | 
						"k8s.io/apimachinery/pkg/util/version"
 | 
				
			||||||
	"k8s.io/klog/v2"
 | 
						"k8s.io/klog/v2"
 | 
				
			||||||
 | 
						"k8s.io/kubernetes/pkg/kubelet/userns/inuserns"
 | 
				
			||||||
	utilkernel "k8s.io/kubernetes/pkg/util/kernel"
 | 
						utilkernel "k8s.io/kubernetes/pkg/util/kernel"
 | 
				
			||||||
	"k8s.io/mount-utils"
 | 
						"k8s.io/mount-utils"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
@@ -46,6 +47,14 @@ func IsTmpfsNoswapOptionSupported(mounter mount.Interface, mountPath string) boo
 | 
				
			|||||||
			return false
 | 
								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()
 | 
							kernelVersion, err := utilkernel.GetVersion()
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			klog.ErrorS(err, "cannot determine kernel version, unable to determine is tmpfs noswap is supported")
 | 
								klog.ErrorS(err, "cannot determine kernel version, unable to determine is tmpfs noswap is supported")
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user