Browse code

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 authored on 2018/12/19 07:41:52
Showing 3 changed files
... ...
@@ -354,7 +354,8 @@ func adaptSharedNamespaceContainer(daemon containerGetter, hostConfig *container
354 354
 	}
355 355
 }
356 356
 
357
-func verifyContainerResources(resources *containertypes.Resources, sysInfo *sysinfo.SysInfo, update bool) (warnings []string, err error) {
357
+// verifyPlatformContainerResources performs platform-specific validation of the container's resource-configuration
358
+func verifyPlatformContainerResources(resources *containertypes.Resources, sysInfo *sysinfo.SysInfo, update bool) (warnings []string, err error) {
358 359
 	fixMemorySwappiness(resources)
359 360
 
360 361
 	// memory subsystem checks and adjustments
... ...
@@ -563,7 +564,7 @@ func UsingSystemd(config *config.Config) bool {
563 563
 func verifyPlatformContainerSettings(daemon *Daemon, hostConfig *containertypes.HostConfig, update bool) (warnings []string, err error) {
564 564
 	sysInfo := sysinfo.New(true)
565 565
 
566
-	w, err := verifyContainerResources(&hostConfig.Resources, sysInfo, update)
566
+	w, err := verifyPlatformContainerResources(&hostConfig.Resources, sysInfo, update)
567 567
 
568 568
 	// no matter err is nil or not, w could have data in itself.
569 569
 	warnings = append(warnings, w...)
... ...
@@ -270,7 +270,7 @@ func TestNetworkOptions(t *testing.T) {
270 270
 	}
271 271
 }
272 272
 
273
-func TestVerifyContainerResources(t *testing.T) {
273
+func TestVerifyPlatformContainerResources(t *testing.T) {
274 274
 	t.Parallel()
275 275
 	var (
276 276
 		no  = false
... ...
@@ -354,7 +354,7 @@ func TestVerifyContainerResources(t *testing.T) {
354 354
 	for _, tc := range tests {
355 355
 		t.Run(tc.name, func(t *testing.T) {
356 356
 			t.Parallel()
357
-			warnings, err := verifyContainerResources(&tc.resources, &tc.sysInfo, tc.update)
357
+			warnings, err := verifyPlatformContainerResources(&tc.resources, &tc.sysInfo, tc.update)
358 358
 			assert.NilError(t, err)
359 359
 			for _, w := range tc.expectedWarnings {
360 360
 				assert.Assert(t, is.Contains(warnings, w))
... ...
@@ -75,7 +75,8 @@ func (daemon *Daemon) adaptContainerSettings(hostConfig *containertypes.HostConf
75 75
 	return nil
76 76
 }
77 77
 
78
-func verifyContainerResources(resources *containertypes.Resources, isHyperv bool) (warnings []string, err error) {
78
+// verifyPlatformContainerResources performs platform-specific validation of the container's resource-configuration
79
+func verifyPlatformContainerResources(resources *containertypes.Resources, isHyperv bool) (warnings []string, err error) {
79 80
 	fixMemorySwappiness(resources)
80 81
 	if !isHyperv {
81 82
 		// The processor resource controls are mutually exclusive on
... ...
@@ -198,7 +199,7 @@ func verifyPlatformContainerSettings(daemon *Daemon, hostConfig *containertypes.
198 198
 		return warnings, fmt.Errorf("Windows client operating systems earlier than version 1809 can only run Hyper-V containers")
199 199
 	}
200 200
 
201
-	w, err := verifyContainerResources(&hostConfig.Resources, hyperv)
201
+	w, err := verifyPlatformContainerResources(&hostConfig.Resources, hyperv)
202 202
 	warnings = append(warnings, w...)
203 203
 	return warnings, err
204 204
 }