Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/source/markdown/podman-container-inspect.1.md.in
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ $ podman container inspect foobar
"KernelMemory": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": 0,
"MemorySwappiness": null,
"OomKillDisable": false,
"PidsLimit": 2048,
"Ulimits": [],
Expand Down
6 changes: 2 additions & 4 deletions libpod/container_inspect_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,8 @@ func (c *Container) platformInspectContainerHostConfig(ctrSpec *spec.Spec, hostC
hostConfig.MemorySwap = *ctrSpec.Linux.Resources.Memory.Swap
}
if ctrSpec.Linux.Resources.Memory.Swappiness != nil {
hostConfig.MemorySwappiness = int64(*ctrSpec.Linux.Resources.Memory.Swappiness)
} else {
// Swappiness has a default of -1
hostConfig.MemorySwappiness = -1
swappiness := int64(*ctrSpec.Linux.Resources.Memory.Swappiness)
hostConfig.MemorySwappiness = &swappiness
}
if ctrSpec.Linux.Resources.Memory.DisableOOMKiller != nil {
hostConfig.OomKillDisable = *ctrSpec.Linux.Resources.Memory.DisableOOMKiller
Expand Down
4 changes: 2 additions & 2 deletions libpod/define/container_inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -643,8 +643,8 @@ type InspectContainerHostConfig struct {
// MemorySwappiness is the willingness of the kernel to page container
// memory to swap. It is an integer from 0 to 100, with low numbers
// being more likely to be put into swap.
// -1, the default, will not set swappiness and use the system defaults.
MemorySwappiness int64 `json:"MemorySwappiness"`
// nil means swappiness is unset and the system default is used.
MemorySwappiness *int64 `json:"MemorySwappiness"`
// OomKillDisable indicates whether the kernel OOM killer is disabled
// for the container.
OomKillDisable bool `json:"OomKillDisable"`
Expand Down
15 changes: 15 additions & 0 deletions test/apiv2/20-containers.at
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,21 @@ t GET containers/$cid/json 200 \
t DELETE containers/$cid 204
podman rmi test1

# test MemorySwappiness
podman run -d --rm --name swappiness_with_mem_limit --memory 200M $IMAGE top
podman run -d --rm --name swappiness_without_mem_limit $IMAGE top

t GET containers/swappiness_with_mem_limit/json 200 \
.HostConfig.MemorySwappiness=null
t GET containers/swappiness_without_mem_limit/json 200 \
.HostConfig.MemorySwappiness=null

t GET libpod/containers/swappiness_with_mem_limit/json 200 \
.HostConfig.MemorySwappiness=null
t GET libpod/containers/swappiness_without_mem_limit/json 200 \
.HostConfig.MemorySwappiness=null

podman stop -t0 swappiness_with_mem_limit swappiness_without_mem_limit

# test if API support -1 for ulimits https://github.com/containers/podman/issues/24886

Expand Down
2 changes: 1 addition & 1 deletion test/e2e/container_clone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ var _ = Describe("Podman container clone", func() {
cloneInspect.WaitWithDefaultTimeout()
Expect(cloneInspect).To(ExitCleanly())
cloneData = cloneInspect.InspectContainerToJSON()
Expect(cloneData[0].HostConfig).To(HaveField("MemorySwappiness", int64(0)))
Expect(cloneData[0].HostConfig.MemorySwappiness).To(BeNil())
})

It("podman container clone in a pod", func() {
Expand Down