From 427b0cd63688a6a167256855c1c3f5fa15ddf889 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 7 Feb 2022 18:06:57 +0100 Subject: [PATCH] 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 --- api/swagger.yaml | 7 ++++++- api/types/container/host_config.go | 19 +++++++++++-------- docs/api/version-history.md | 2 ++ 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/api/swagger.yaml b/api/swagger.yaml index 0164e37b67..edd356e0f9 100644 --- a/api/swagger.yaml +++ b/api/swagger.yaml @@ -578,7 +578,12 @@ definitions: items: $ref: "#/definitions/DeviceRequest" 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" format: "int64" MemoryReservation: diff --git a/api/types/container/host_config.go b/api/types/container/host_config.go index dcea6c8a5a..9a5aa28f9a 100644 --- a/api/types/container/host_config.go +++ b/api/types/container/host_config.go @@ -376,14 +376,17 @@ type Resources struct { Devices []DeviceMapping // List of devices to map inside the container DeviceCgroupRules []string // List of rule to be added to the device cgroup 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 CPUCount int64 `json:"CpuCount"` // CPU count diff --git a/docs/api/version-history.md b/docs/api/version-history.md index c0d45d27e1..3cf25ee5d1 100644 --- a/docs/api/version-history.md +++ b/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 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. +* `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 supported by the host or host's configuration (if cgroups v2 are in use).