mirror of
https://github.com/containerd/containerd.git
synced 2026-08-12 22:16:27 +00:00
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>