mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 12:43:23 +00:00
If the kernel version is at least 6.4, assume tmpfs noswap is supported
Signed-off-by: Itamar Holder <iholder@redhat.com>
This commit is contained in:
parent
3b9b03935e
commit
2a174d09fa
@ -21,7 +21,9 @@ import (
|
||||
sysruntime "runtime"
|
||||
"sync"
|
||||
|
||||
"k8s.io/apimachinery/pkg/util/version"
|
||||
"k8s.io/klog/v2"
|
||||
utilkernel "k8s.io/kubernetes/pkg/util/kernel"
|
||||
"k8s.io/mount-utils"
|
||||
)
|
||||
|
||||
@ -38,6 +40,16 @@ func IsTmpfsNoswapOptionSupported(mounter mount.Interface) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
kernelVersion, err := utilkernel.GetVersion()
|
||||
if err != nil {
|
||||
klog.ErrorS(err, "cannot determine kernel version, unable to determine is tmpfs noswap is supported")
|
||||
return false
|
||||
}
|
||||
|
||||
if kernelVersion.AtLeast(version.MustParseGeneric(utilkernel.TmpfsNoswapSupportKernelVersion)) {
|
||||
return true
|
||||
}
|
||||
|
||||
mountDir, err := os.MkdirTemp("", "tmpfs-noswap-test-")
|
||||
if err != nil {
|
||||
klog.InfoS("error creating dir to test if tmpfs noswap is enabled. Assuming not supported", "mount path", mountDir, "error", err)
|
||||
|
@ -47,3 +47,5 @@ const IPVSConnReuseModeFixedKernelVersion = "5.9"
|
||||
// UserNamespacesSupportKernelVersion is the kernel version where idmap for tmpfs support was added
|
||||
// (ref: https://github.com/torvalds/linux/commit/05e6295f7b5e05f09e369a3eb2882ec5b40fff20)
|
||||
const UserNamespacesSupportKernelVersion = "6.3"
|
||||
|
||||
const TmpfsNoswapSupportKernelVersion = "6.4"
|
||||
|
Loading…
Reference in New Issue
Block a user