瀏覽代碼

Rename verifyContainerResources to verifyPlatformContainerResources

This validation function is platform-specific; rename it to be
more explicit.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn 6 年之前
父節點
當前提交
b6e373c525
共有 3 個文件被更改,包括 8 次插入6 次删除
  1. 3 2
      daemon/daemon_unix.go
  2. 2 2
      daemon/daemon_unix_test.go
  3. 3 2
      daemon/daemon_windows.go

+ 3 - 2
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...)

+ 2 - 2
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))

+ 3 - 2
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
 }