diff --git a/daemon/daemon_unix.go b/daemon/daemon_unix.go index b0f23bcb79..cd8f4878be 100644 --- a/daemon/daemon_unix.go +++ b/daemon/daemon_unix.go @@ -354,7 +354,8 @@ func adaptSharedNamespaceContainer(daemon containerGetter, hostConfig *container } } -func verifyContainerResources(resources *containertypes.Resources, sysInfo *sysinfo.SysInfo, update bool) (warnings []string, err error) { +// verifyPlatformContainerResources performs platform-specific validation of the container's resource-configuration +func verifyPlatformContainerResources(resources *containertypes.Resources, sysInfo *sysinfo.SysInfo, update bool) (warnings []string, err error) { fixMemorySwappiness(resources) // memory subsystem checks and adjustments @@ -563,7 +564,7 @@ func UsingSystemd(config *config.Config) bool { func verifyPlatformContainerSettings(daemon *Daemon, hostConfig *containertypes.HostConfig, update bool) (warnings []string, err error) { sysInfo := sysinfo.New(true) - w, err := verifyContainerResources(&hostConfig.Resources, sysInfo, update) + w, err := verifyPlatformContainerResources(&hostConfig.Resources, sysInfo, update) // no matter err is nil or not, w could have data in itself. warnings = append(warnings, w...) diff --git a/daemon/daemon_unix_test.go b/daemon/daemon_unix_test.go index fed00207a5..c8575ad8da 100644 --- a/daemon/daemon_unix_test.go +++ b/daemon/daemon_unix_test.go @@ -270,7 +270,7 @@ func TestNetworkOptions(t *testing.T) { } } -func TestVerifyContainerResources(t *testing.T) { +func TestVerifyPlatformContainerResources(t *testing.T) { t.Parallel() var ( no = false @@ -354,7 +354,7 @@ func TestVerifyContainerResources(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { t.Parallel() - warnings, err := verifyContainerResources(&tc.resources, &tc.sysInfo, tc.update) + warnings, err := verifyPlatformContainerResources(&tc.resources, &tc.sysInfo, tc.update) assert.NilError(t, err) for _, w := range tc.expectedWarnings { assert.Assert(t, is.Contains(warnings, w)) diff --git a/daemon/daemon_windows.go b/daemon/daemon_windows.go index a7879db346..e62795814d 100644 --- a/daemon/daemon_windows.go +++ b/daemon/daemon_windows.go @@ -75,7 +75,8 @@ func (daemon *Daemon) adaptContainerSettings(hostConfig *containertypes.HostConf return nil } -func verifyContainerResources(resources *containertypes.Resources, isHyperv bool) (warnings []string, err error) { +// verifyPlatformContainerResources performs platform-specific validation of the container's resource-configuration +func verifyPlatformContainerResources(resources *containertypes.Resources, isHyperv bool) (warnings []string, err error) { fixMemorySwappiness(resources) if !isHyperv { // The processor resource controls are mutually exclusive on @@ -198,7 +199,7 @@ func verifyPlatformContainerSettings(daemon *Daemon, hostConfig *containertypes. return warnings, fmt.Errorf("Windows client operating systems earlier than version 1809 can only run Hyper-V containers") } - w, err := verifyContainerResources(&hostConfig.Resources, hyperv) + w, err := verifyPlatformContainerResources(&hostConfig.Resources, hyperv) warnings = append(warnings, w...) return warnings, err }