Browse code

Deprecate KernelMemory

Kernel memory limit is not supported on cgroup v2.
Even on cgroup v1, kernel memory limit (`kmem.limit_in_bytes`) has been deprecated since kernel 5.4.
https://github.com/torvalds/linux/commit/0158115f702b0ba208ab0b5adf44cae99b3ebcc7

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>

Akihiro Suda authored on 2020/07/24 17:20:56
Showing 6 changed files
... ...
@@ -528,7 +528,13 @@ definitions:
528 528
         items:
529 529
           $ref: "#/definitions/DeviceRequest"
530 530
       KernelMemory:
531
-        description: "Kernel memory limit in bytes."
531
+        description: |
532
+          Kernel memory limit in bytes.
533
+
534
+          <p><br /></p>
535
+
536
+          > **Deprecated**: This field is deprecated as the kernel 5.4 deprecated
537
+          > `kmem.limit_in_bytes`.
532 538
         type: "integer"
533 539
         format: "int64"
534 540
         example: 209715200
... ...
@@ -4321,7 +4327,13 @@ definitions:
4321 4321
         type: "boolean"
4322 4322
         example: true
4323 4323
       KernelMemory:
4324
-        description: "Indicates if the host has kernel memory limit support enabled."
4324
+        description: |
4325
+          Indicates if the host has kernel memory limit support enabled.
4326
+
4327
+          <p><br /></p>
4328
+
4329
+          > **Deprecated**: This field is deprecated as the kernel 5.4 deprecated
4330
+          > `kmem.limit_in_bytes`.
4325 4331
         type: "boolean"
4326 4332
         example: true
4327 4333
       CpuCfsPeriod:
... ...
@@ -361,7 +361,7 @@ type Resources struct {
361 361
 	Devices              []DeviceMapping // List of devices to map inside the container
362 362
 	DeviceCgroupRules    []string        // List of rule to be added to the device cgroup
363 363
 	DeviceRequests       []DeviceRequest // List of device requests for device drivers
364
-	KernelMemory         int64           // Kernel memory limit (in bytes)
364
+	KernelMemory         int64           // Kernel memory limit (in bytes), Deprecated: kernel 5.4 deprecated kmem.limit_in_bytes
365 365
 	KernelMemoryTCP      int64           // Hard limit for kernel TCP buffer memory (in bytes)
366 366
 	MemoryReservation    int64           // Memory soft limit (in bytes)
367 367
 	MemorySwap           int64           // Total memory usage (memory + swap); set `-1` to enable unlimited swap
... ...
@@ -158,7 +158,7 @@ type Info struct {
158 158
 	Plugins            PluginsInfo
159 159
 	MemoryLimit        bool
160 160
 	SwapLimit          bool
161
-	KernelMemory       bool
161
+	KernelMemory       bool // Deprecated: kernel 5.4 deprecated kmem.limit_in_bytes
162 162
 	KernelMemoryTCP    bool
163 163
 	CPUCfsPeriod       bool `json:"CpuCfsPeriod"`
164 164
 	CPUCfsQuota        bool `json:"CpuCfsQuota"`
... ...
@@ -465,6 +465,12 @@ func verifyPlatformContainerResources(resources *containertypes.Resources, sysIn
465 465
 	if resources.Memory > 0 && resources.MemoryReservation > 0 && resources.Memory < resources.MemoryReservation {
466 466
 		return warnings, fmt.Errorf("Minimum memory limit can not be less than memory reservation limit, see usage")
467 467
 	}
468
+	if resources.KernelMemory > 0 {
469
+		// Kernel memory limit is not supported on cgroup v2.
470
+		// Even on cgroup v1, kernel memory limit (`kmem.limit_in_bytes`) has been deprecated since kernel 5.4.
471
+		// https://github.com/torvalds/linux/commit/0158115f702b0ba208ab0b5adf44cae99b3ebcc7
472
+		warnings = append(warnings, "Specifying a kernel memory limit is deprecated and will be removed in a future release.")
473
+	}
468 474
 	if resources.KernelMemory > 0 && !sysInfo.KernelMemory {
469 475
 		warnings = append(warnings, "Your kernel does not support kernel memory limit capabilities or the cgroup is not mounted. Limitation discarded.")
470 476
 		resources.KernelMemory = 0
... ...
@@ -100,9 +100,6 @@ func (daemon *Daemon) fillPlatformInfo(v *types.Info, sysInfo *sysinfo.SysInfo)
100 100
 		if !v.SwapLimit {
101 101
 			v.Warnings = append(v.Warnings, "WARNING: No swap limit support")
102 102
 		}
103
-		if !v.KernelMemory {
104
-			v.Warnings = append(v.Warnings, "WARNING: No kernel memory limit support")
105
-		}
106 103
 		if !v.KernelMemoryTCP {
107 104
 			v.Warnings = append(v.Warnings, "WARNING: No kernel memory TCP limit support")
108 105
 		}
... ...
@@ -74,6 +74,8 @@ keywords: "API, Docker, rcli, REST, documentation"
74 74
   job-mode service.
75 75
 * `GET /containers/{id}/stats` now accepts a query param (`one-shot`) which, when used with `stream=false` fetches a
76 76
   single set of stats instead of waiting for two collection cycles to have 2 CPU stats over a 1 second period.
77
+* The `KernelMemory` field in `HostConfig.Resources` is now deprecated.
78
+* The `KernelMemory` field in `Info` is now deprecated.
77 79
 
78 80
 ## v1.40 API changes
79 81