Merge pull request #29237 from gastoner/add-memavailable-support
Some checks are pending
ci / path-filter (push) Waiting to run
ci / Validate source code changes (push) Waiting to run
ci / Cross Build (Linux, FreeBSD) (push) Waiting to run
ci / build debian-sid (push) Waiting to run
ci / build fedora-current (push) Waiting to run
ci / build fedora-prior (push) Waiting to run
ci / build fedora-rawhide (push) Waiting to run
ci / windows installer hyperv (push) Waiting to run
ci / windows installer wsl (push) Waiting to run
ci / macos installer (push) Waiting to run
ci / int local root debian-sid (push) Blocked by required conditions
ci / sys local root debian-sid (push) Blocked by required conditions
ci / int local rootless debian-sid (push) Blocked by required conditions
ci / sys local rootless debian-sid (push) Blocked by required conditions
ci / int remote root debian-sid (push) Blocked by required conditions
ci / sys remote root debian-sid (push) Blocked by required conditions
ci / bud local root fedora-current (push) Blocked by required conditions
ci / int local root fedora-current (push) Blocked by required conditions
ci / sys local root fedora-current (push) Blocked by required conditions
ci / int local rootless fedora-current (push) Blocked by required conditions
ci / sys local rootless fedora-current (push) Blocked by required conditions
ci / bud remote root fedora-current (push) Blocked by required conditions
ci / int remote root fedora-current (push) Blocked by required conditions
ci / sys remote root fedora-current (push) Blocked by required conditions
ci / int remote rootless fedora-current (push) Blocked by required conditions
ci / sys remote rootless fedora-current (push) Blocked by required conditions
ci / int local root fedora-prior (push) Blocked by required conditions
ci / sys local root fedora-prior (push) Blocked by required conditions
ci / int local rootless fedora-prior (push) Blocked by required conditions
ci / sys local rootless fedora-prior (push) Blocked by required conditions
ci / int remote root fedora-prior (push) Blocked by required conditions
ci / sys remote root fedora-prior (push) Blocked by required conditions
ci / int local root fedora-rawhide (push) Blocked by required conditions
ci / sys local root fedora-rawhide (push) Blocked by required conditions
ci / int local rootless fedora-rawhide (push) Blocked by required conditions
ci / sys local rootless fedora-rawhide (push) Blocked by required conditions
ci / int remote root fedora-rawhide (push) Blocked by required conditions
ci / sys remote root fedora-rawhide (push) Blocked by required conditions
ci / apiv2 root fedora-current (push) Blocked by required conditions
ci / bindings root fedora-current (push) Blocked by required conditions
ci / compose_v2 root fedora-current (push) Blocked by required conditions
ci / docker_py root fedora-current (push) Blocked by required conditions
ci / unit root fedora-current (push) Blocked by required conditions
ci / apiv2 rootless fedora-current (push) Blocked by required conditions
ci / compose_v2 rootless fedora-current (push) Blocked by required conditions
ci / unit rootless fedora-current (push) Blocked by required conditions
ci / upgrade v5.3.1 root fedora-current (push) Blocked by required conditions
ci / upgrade v5.6.2 root fedora-current (push) Blocked by required conditions
ci / machine linux amd64 (push) Blocked by required conditions
ci / windows unit (push) Blocked by required conditions
ci / windows e2e (push) Blocked by required conditions
ci / windows machine hyperv (push) Blocked by required conditions
ci / windows machine wsl (push) Blocked by required conditions
ci / macos machine applehv (push) Blocked by required conditions
ci / macos machine libkrun (push) Blocked by required conditions
ci / Total Success (push) Blocked by required conditions
zizmor: GitHub Actions Security Analysis / Zizmor (push) Waiting to run

feat(info): add memAvailable to host info
This commit is contained in:
Jan Rodák 2026-07-22 10:15:52 +02:00 committed by GitHub
commit c0fb461475
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 38 additions and 1 deletions

View file

@ -75,6 +75,7 @@ host:
kernel: 5.13.13-200.fc34.x86_64
linkmode: dynamic
logDriver: journald
memAvailable: 14567456768
memFree: 1833385984
memTotal: 16401895424
networkBackend: netavark
@ -218,6 +219,7 @@ $ podman info --format json
},
"kernel": "5.13.13-200.fc34.x86_64",
"logDriver": "journald",
"memAvailable": 14567456768,
"memFree": 1785753600,
"memTotal": 16401895424,
"networkBackend": "netavark",

View file

@ -47,6 +47,7 @@ type HostInfo struct {
Kernel string `json:"kernel"`
LogDriver string `json:"logDriver"`
MemFree int64 `json:"memFree"`
MemAvailable int64 `json:"memAvailable"`
MemTotal int64 `json:"memTotal"`
NetworkBackend string `json:"networkBackend"`
NetworkBackendInfo types.NetworkInfo `json:"networkBackendInfo"`

View file

@ -122,6 +122,7 @@ func (r *Runtime) hostInfo() (*define.HostInfo, error) {
Hostname: host,
Kernel: kv,
MemFree: mi.MemFree,
MemAvailable: mi.MemAvailable,
MemTotal: mi.MemTotal,
NetworkBackend: r.config.Network.NetworkBackend,
NetworkBackendInfo: r.network.NetworkInfo(),

View file

@ -12,7 +12,10 @@ t GET /v1.52/system/df 200 '{"ImageUsage":{},"ContainerUsage":{},"VolumeUsage":{
t GET libpod/system/df 200 '{"ImagesSize":0,"Images":[],"Containers":[],"Volumes":[]}'
# Create volume. We expect df to report this volume next invocation of system/df
t GET libpod/info 200
t GET libpod/info 200 \
.host.memTotal~[0-9]\\+ \
.host.memFree~[0-9]\\+ \
.host.memAvailable~[0-9]\\+
volumepath=$(jq -r ".store.volumePath" <<<"$output")
t POST libpod/volumes/create name=foo1 201 \
.Name=foo1 \

View file

@ -244,6 +244,21 @@ var _ = Describe("Podman Info", func() {
}
})
It("Podman info: check host.memAvailable is sane", func() {
session := podmanTest.PodmanExitCleanly("info", "--format", "{{.Host.MemTotal}} {{.Host.MemAvailable}}")
var total, avail int64
_, err := fmt.Sscanf(session.OutputToString(), "%d %d", &total, &avail)
Expect(err).ToNot(HaveOccurred())
// On Linux, MemAvailable must always be reported; -1 is the
// sentinel used on platforms where the kernel doesn't expose
// this value.
Expect(avail).To(BeNumerically(">=", 0), "MemAvailable is supported (not the -1 'unknown' sentinel)")
// MemAvailable (reclaimable memory included) can never exceed MemTotal.
Expect(avail).To(BeNumerically("<=", total), "MemAvailable does not exceed MemTotal")
})
It("Podman info: check lock count", Serial, func() {
// This should not run on architectures and OSes that use the file locks backend.
// Which, for now, is Linux + RISCV and FreeBSD, neither of which are in CI - so

View file

@ -44,6 +44,9 @@ host.conmon.path | $expr_path
host.conmon.package | .*conmon.*
host.cgroupManager | \\\(systemd\\\|cgroupfs\\\)
host.cgroupVersion | v[12]
host.memFree | [0-9]\\\+
host.memAvailable | [0-9]\\\+
host.memTotal | [0-9]\\\+
host.networkBackendInfo | .*dns.*package.*
host.ociRuntime.path | $expr_path
host.pasta | .*executable.*package.*
@ -62,6 +65,18 @@ store.imageStore.number | 1
done < <(parse_table "$tests")
}
@test "podman info - host.memAvailable is sane" {
run_podman info --format '{{.Host.MemTotal}} {{.Host.MemAvailable}}'
read -r total avail <<<"$output"
# On Linux, MemAvailable must always be reported; -1 is the sentinel
# used on platforms where the kernel doesn't expose this value.
assert "$avail" -ge 0 "MemAvailable is supported (not the -1 'unknown' sentinel)"
# MemAvailable (reclaimable memory included) can never exceed MemTotal.
assert "$avail" -le "$total" "MemAvailable does not exceed MemTotal"
}
@test "podman info - confirm desired runtime" {
if [[ -z "$CI_DESIRED_RUNTIME" ]]; then
# When running in Cirrus, CI_DESIRED_RUNTIME *must* be defined