]> git.feebdaed.xyz Git - 0xmirror/containerd.git/commit
Fix nil pointer dereference in container spec memory metrics
authorYou Binhao <ymichaelson.0713@gmail.com>
Thu, 6 Nov 2025 11:50:13 +0000 (19:50 +0800)
committerYou Binhao <ymichaelson.0713@gmail.com>
Thu, 6 Nov 2025 12:07:26 +0000 (20:07 +0800)
commit6b82f034de52f05124d633b16fa23c548c4ce285
tree1f33b28c322da3cacff14d088571e7840394ef78
parent1c4457e00facac03ce1d75f7b6777a7a851e5c41
Fix nil pointer dereference in container spec memory metrics

Add nil checks for Memory.Limit, Memory.Reservation, and Memory.Swap
before dereferencing them in extractContainerSpecMetrics. These fields
are optional pointers in OCI runtime spec and can be nil when not set.

- Memory.Limit: Set from Pod resources.limits.memory
- Memory.Reservation: Only set via NRI plugins (rarely used)
- Memory.Swap: Set from memory_swap_limit_in_bytes (optional)

This prevents potential panic when collecting metrics from containers
that don't have all memory limits configured, and makes the code
consistent with CPU resource handling and helpers.go.

Signed-off-by: You Binhao <ymichaelson.0713@gmail.com>
internal/cri/server/list_pod_sandbox_metrics_linux.go