mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 10:25:42 +03:00
drivers/docker: fix a hostConfigMemorySwappiness panic (#18238)
cgroupslib.MaybeDisableMemorySwappiness returned an incorrect type, and was incorrectly typecast to int64 causing a panic on non-linux and non-windows hosts.
This commit is contained in:
committed by
GitHub
parent
e21ab7d948
commit
53ef6391a5
@@ -11,6 +11,6 @@ func LinuxResourcesPath(string, string) string {
|
||||
}
|
||||
|
||||
// MaybeDisableMemorySwappiness does nothing on non-Linux systems
|
||||
func MaybeDisableMemorySwappiness() *int {
|
||||
func MaybeDisableMemorySwappiness() *uint64 {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import (
|
||||
"github.com/hashicorp/nomad/drivers/shared/hostnames"
|
||||
"github.com/hashicorp/nomad/drivers/shared/resolvconf"
|
||||
"github.com/hashicorp/nomad/helper"
|
||||
"github.com/hashicorp/nomad/helper/pointer"
|
||||
nstructs "github.com/hashicorp/nomad/nomad/structs"
|
||||
"github.com/hashicorp/nomad/plugins/base"
|
||||
"github.com/hashicorp/nomad/plugins/drivers"
|
||||
@@ -1035,8 +1036,11 @@ func (d *Driver) createContainerConfig(task *drivers.TaskConfig, driverConfig *T
|
||||
hostConfig.MemorySwap = memory
|
||||
|
||||
// disable swap explicitly in non-Windows environments
|
||||
swappiness := int64(*(cgroupslib.MaybeDisableMemorySwappiness()))
|
||||
hostConfig.MemorySwappiness = &swappiness
|
||||
if cgroupslib.MaybeDisableMemorySwappiness() != nil {
|
||||
hostConfig.MemorySwappiness = pointer.Of(int64(*(cgroupslib.MaybeDisableMemorySwappiness())))
|
||||
} else {
|
||||
hostConfig.MemorySwappiness = nil
|
||||
}
|
||||
}
|
||||
|
||||
loggingDriver := driverConfig.Logging.Type
|
||||
|
||||
Reference in New Issue
Block a user