Jelajahi Sumber

api/types: fix KernelMemory deprecation comment, and omitempty

This fixes the "deprecated" comment to have the correct format to be picked
up by editors, and adds `omitempty` labels for KernelMemory and KernelMemoryTCP.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn 3 tahun lalu
induk
melakukan
427b0cd636
3 mengubah file dengan 19 tambahan dan 9 penghapusan
  1. 6 1
      api/swagger.yaml
  2. 11 8
      api/types/container/host_config.go
  3. 2 0
      docs/api/version-history.md

+ 6 - 1
api/swagger.yaml

@@ -578,7 +578,12 @@ definitions:
         items:
         items:
           $ref: "#/definitions/DeviceRequest"
           $ref: "#/definitions/DeviceRequest"
       KernelMemoryTCP:
       KernelMemoryTCP:
-        description: "Hard limit for kernel TCP buffer memory (in bytes)."
+        description: |
+          Hard limit for kernel TCP buffer memory (in bytes). Depending on the
+          OCI runtime in use, this option may be ignored. It is no longer supported
+          by the default (runc) runtime.
+
+          This field is omitted when empty.
         type: "integer"
         type: "integer"
         format: "int64"
         format: "int64"
       MemoryReservation:
       MemoryReservation:

+ 11 - 8
api/types/container/host_config.go

@@ -376,14 +376,17 @@ type Resources struct {
 	Devices              []DeviceMapping // List of devices to map inside the container
 	Devices              []DeviceMapping // List of devices to map inside the container
 	DeviceCgroupRules    []string        // List of rule to be added to the device cgroup
 	DeviceCgroupRules    []string        // List of rule to be added to the device cgroup
 	DeviceRequests       []DeviceRequest // List of device requests for device drivers
 	DeviceRequests       []DeviceRequest // List of device requests for device drivers
-	KernelMemory         int64           // Kernel memory limit (in bytes), Deprecated: kernel 5.4 deprecated kmem.limit_in_bytes
-	KernelMemoryTCP      int64           // Hard limit for kernel TCP buffer memory (in bytes)
-	MemoryReservation    int64           // Memory soft limit (in bytes)
-	MemorySwap           int64           // Total memory usage (memory + swap); set `-1` to enable unlimited swap
-	MemorySwappiness     *int64          // Tuning container memory swappiness behaviour
-	OomKillDisable       *bool           // Whether to disable OOM Killer or not
-	PidsLimit            *int64          // Setting PIDs limit for a container; Set `0` or `-1` for unlimited, or `null` to not change.
-	Ulimits              []*units.Ulimit // List of ulimits to be set in the container
+
+	// KernelMemory specifies the kernel memory limit (in bytes) for the container.
+	// Deprecated: kernel 5.4 deprecated kmem.limit_in_bytes.
+	KernelMemory      int64           `json:",omitempty"`
+	KernelMemoryTCP   int64           `json:",omitempty"` // Hard limit for kernel TCP buffer memory (in bytes)
+	MemoryReservation int64           // Memory soft limit (in bytes)
+	MemorySwap        int64           // Total memory usage (memory + swap); set `-1` to enable unlimited swap
+	MemorySwappiness  *int64          // Tuning container memory swappiness behaviour
+	OomKillDisable    *bool           // Whether to disable OOM Killer or not
+	PidsLimit         *int64          // Setting PIDs limit for a container; Set `0` or `-1` for unlimited, or `null` to not change.
+	Ulimits           []*units.Ulimit // List of ulimits to be set in the container
 
 
 	// Applicable to Windows
 	// Applicable to Windows
 	CPUCount           int64  `json:"CpuCount"`   // CPU count
 	CPUCount           int64  `json:"CpuCount"`   // CPU count

+ 2 - 0
docs/api/version-history.md

@@ -46,6 +46,8 @@ keywords: "API, Docker, rcli, REST, documentation"
   `POST /containers/{id}/update` endpoints, any value it is set to will be ignored
   `POST /containers/{id}/update` endpoints, any value it is set to will be ignored
   on API version `v1.42` and up. Older API versions still accept this field, but
   on API version `v1.42` and up. Older API versions still accept this field, but
   may take no effect, depending on the kernel version and OCI runtime in use.
   may take no effect, depending on the kernel version and OCI runtime in use.
+* `GET /containers/{id}/json` now omits the `KernelMemory` and `KernelMemoryTCP`
+  if they are not set.
 * `GET /info` now omits the `KernelMemory` and `KernelMemoryTCP` if they are not
 * `GET /info` now omits the `KernelMemory` and `KernelMemoryTCP` if they are not
   supported by the host or host's configuration (if cgroups v2 are in use).
   supported by the host or host's configuration (if cgroups v2 are in use).