Commit Graph

378 Commits

Author SHA1 Message Date
Maksym Pavlenko
fb805016c4 Merge pull request #12773 from mxpv/podsandbox
cri/podsandbox: reduce dependencies to internal CRI APIs
2026-01-17 07:04:37 +00:00
Maksym Pavlenko
87a16b2695 Merge pull request #12769 from klihub/devel/main/nri-input/container-user
cri,nri: pass container user (uid, gids) to plugins.
2026-01-13 19:42:42 +00:00
Fu Wei
704a2ff7eb Merge pull request #12763 from ningmingxiao/chekpoint_2
cri: fix create container panic if originalAnnotations is nil
2026-01-13 19:42:05 +00:00
Maksym Pavlenko
7ef50acccf Reduce ImageService interface dependencies
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2026-01-13 09:05:08 -08:00
Krisztian Litkey
b0bd04b046 cri,nri: pass container user (uid, gids) to plugins.
Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
2026-01-13 07:59:37 -06:00
Krisztian Litkey
cfec4b30a7 cri,nri: pass seccomp policy to plugins.
Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
2026-01-12 09:59:58 -06:00
Derek McGowan
eb888dce45 Merge pull request #12765 from klihub/devel/main/nri-input/rlimits
cri,nri: pass any POSIX rlimits to plugins.
2026-01-12 15:02:52 +00:00
Fu Wei
cdc56ea306 Merge pull request #12758 from ningmingxiao/check_point_1
cri: fix checkpoint failed with short id
2026-01-12 14:22:12 +00:00
ningmingxiao
9018c75d5d cri: fix create container panic if originalAnnotations is nil when restore container
Signed-off-by: ningmingxiao <ning.mingxiao@zte.com.cn>
2026-01-12 15:13:06 +08:00
Krisztian Litkey
7b85525cfe cri,nri: pass any POSIX rlimits to plugins.
Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
2026-01-11 18:16:50 +02:00
Krisztian Litkey
695c91324a cri,nri: pass extended container status to NRI.
Pass more complete container status information to NRI, including
exit code, and timestamps for container creation, start, and exit
events.

Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
2026-01-10 10:50:07 +02:00
Maksym Pavlenko
04366a910a Merge pull request #12767 from klihub/devel/main/nri-input/cdi-devices
cri,nri: pass injected CDI devices to plugins.
2026-01-09 23:30:48 +00:00
Derek McGowan
8e2aa0b9e8 Merge pull request #12766 from klihub/devel/main/nri-input/sysctl
cri,nri: pass linux sysctl to plugins.
2026-01-09 22:44:41 +00:00
Krisztian Litkey
98a2e88767 cri,nri: pass injected CDI devices to plugins.
Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
2026-01-09 15:19:32 -06:00
ningmingxiao
0dc9582295 cri: fix checkpoint failed with short id
Signed-off-by: ningmingxiao <ning.mingxiao@zte.com.cn>
2026-01-09 10:47:37 -06:00
Krisztian Litkey
250388dcd9 cri,nri: pass linux sysctl to plugins.
Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
2026-01-09 14:37:52 +02:00
Cindia-blue
fb295b9d4f Tracing: add spans in task/metadata and sandbox paths
This PR adds opt-in tracing spans/attributes in CRI image pull and selected sandbox-related paths to improve debugging and correlation (e.g., sandbox.id/pod metadata). If maintainers prefer a smaller diff, I’m happy to split this into a pull-only PR plus follow-ups.
• follow-up after pull-only PR
• focuses on task/metadata/sandbox/cni setup spans

Signed-off-by: Cindy Li <cindyli@pinterest.com>
2026-01-09 00:05:37 +00:00
Chris Henzie
de5b622bd9 Persist pod sandbox resource updates
Introduces changes to make pod sandbox updates persistent across
restarts.

This is achieved by:
- Storing the updated Overhead and Resources as an extension on the core
  sandbox object and in the in-memory sandbox status store.
- Modifying the sandbox recovery logic to read this extension on startup
  (this is not working in recovery unit tests yet and needs fixing).
- Updating the PodSandboxStatus CRI handler to include updated resources
  from the sandbox status store.

Signed-off-by: Chris Henzie <chrishenzie@google.com>
2026-01-07 09:44:46 -08:00
Chris Henzie
ffd3691c92 Implement UpdatePodSandboxResources CRI API handler
Signed-off-by: Chris Henzie <chrishenzie@google.com>
2026-01-07 09:44:46 -08:00
Wei Fu
016f4a6360 *: move new oom package into internal
Signed-off-by: Wei Fu <fuweid89@gmail.com>
2026-01-06 20:44:04 -05:00
Wei Fu
aa3c507925 internal/cri/server: check if OOM event occurred before update status
Signed-off-by: Wei Fu <fuweid89@gmail.com>
2026-01-06 20:44:04 -05:00
Maksym Pavlenko
253fbe756a Cleanup unit tests
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2026-01-06 10:52:49 -08:00
Anuj Singh
b66f92f591 cri: update log level to warn for CNI load failure during init
Signed-off-by: Anuj Singh <singholt@amazon.com>
2026-01-05 17:40:00 -06:00
Mike Brown
1e154a8b25 Merge pull request #12695 from samuelkarp/concurrent-create-container
cri: emit warning for concurrent CreateContainer
2025-12-23 21:16:05 +00:00
Mike Brown
cdc828fdc5 Merge pull request #12710 from fidencio/fix-snapshotter-per-runtime-handler
cri: Use the runtimeHandler parameter in PullImage
2025-12-22 15:35:12 +00:00
Davanum Srinivas
25dde29394 Merge pull request #12704 from dims/ensure-ListMetricDescriptors-gets-tested-with-latest-k/k
Ensure ListMetricDescriptors gets tested with latest k/k
2025-12-22 13:22:07 +00:00
Mike Brown
34ba1eac32 Merge pull request #12675 from klihub/fixes/main/error-on-disabled-cdi
cri: deprecate `enable_cdi`, treat disabled CDI an error for injection requests.
2025-12-20 18:26:45 +00:00
Davanum Srinivas
a31236b4d0 cri: populate Network.Interfaces in PodSandboxStats on Linux
Added getAllContainerNetIO() to collect stats for all interfaces in
the pod's network namespace.

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2025-12-19 19:40:17 -05:00
Fabiano Fidêncio
b8ae0412ff cri: Use the runtimeHandler parameter in PullImage
The runtimeHandler parameter was added to PullImage() but never used.
Instead, the code relied on an experimental annotation
(io.containerd.cri.runtime-handler) passed in the pod sandbox config.

This annotation was a workaround because CRI's PullImageRequest didn't
include the runtime handler. However, since cri-api v0.29.0, the runtime
handler is available in the API and passed as a parameter to PullImage().

For backward compatibility with CRI clients that don't yet pass the
runtime handler parameter, we fall back to the annotation if the
parameter is empty. The annotation-based fallback is deprecated and
will be removed in containerd 2.5.

Signed-off-by: Wedson Almeida Filho <walmeida@microsoft.com>
Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com>
2025-12-20 01:27:55 +01:00
Samuel Karp
f2ad3aedbc cri: move noisy CDI logs to debug level
WithCDI currently emits logs at Info level for every container even when
len(Config.CDIDevices) == 0.  Move these to Debug level.

Signed-off-by: Samuel Karp <samuelkarp@google.com>
2025-12-19 11:42:08 -08:00
Chris Adeniyi-Jones
c0052e1c69 Reinstate image decryption
Signed-off-by: Chris Adeniyi-Jones <chris.adeniyi-jones@arm.com>
2025-12-18 21:57:37 +00:00
Krisztian Litkey
6936558df9 cri,nri: pass any linux security profile to plugins.
Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
2025-12-17 15:34:03 +02:00
Krisztian Litkey
f202a6989c cri,nri: pass any linux RDT constraints to plugins.
Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
2025-12-17 15:34:03 +02:00
Krisztian Litkey
eb616d8cab cri,nri: pass any linux net devices to plugins.
Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
2025-12-17 15:33:58 +02:00
Krisztian Litkey
239f69aa02 cri,nri: pass any linux scheduler attributes to plugins.
Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
2025-12-17 15:33:58 +02:00
Krisztian Litkey
8e143b2eaa cri,nri: pass any linux I/O priority to plugins.
Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
2025-12-17 15:33:53 +02:00
Krisztian Litkey
ec89339995 cri: treat disabled CDI an error for injection requests.
If a container has CDI devices requested by the dedicated CRI protocol
field, treat this as an error if CDI support is explicitly disabled by
configuration, instead of silently ignoring the requested devices.

Additionally, if CDI support is disabled log a warning about the future
deprecation of the EnableCDI configuration option.

Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
2025-12-17 10:52:54 +02:00
Krisztian Litkey
c49379c38a cri: deprecate the enable_cdi config option.
Deprecate the enable_cdi config option for CRI. Change it to a
pointer so we can differentiate between an unset value and one
that is set explicitly to false. Treat an omitted setting (nil
value) as enabled. Mark it deprecated in RELEASES.md. Add a
deprecation warning for it. Log that warning if we start up
with enable_cdi explicitly set to false.

Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
2025-12-17 10:52:54 +02:00
Samuel Karp
c94b42332b cri: emit warning for concurrent CreateContainer
We have existing detection for concurrent CreateContainer requests, but
the error message is unclear and there is no warning in containerd logs.
This change adds a warning and clarifies the error message.

Signed-off-by: Samuel Karp <samuelkarp@google.com>
2025-12-16 16:45:13 -08:00
Davanum Srinivas
28f75119ba cri: simplify network stats to only add Timestamp field
Remove unnecessary variable extraction and Interfaces field,
keeping only the Timestamp addition as originally intended.

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2025-12-08 16:03:06 -05:00
Davanum Srinivas
218ef1613e Removed the circular dependency
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2025-12-08 16:03:06 -05:00
Davanum Srinivas
7e5809bcfe stats_collection_period -> stats_collect_period
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2025-12-08 16:03:06 -05:00
Davanum Srinivas
9d5ee65014 cri: Add background stats collector to calculate UsageNanoCores
adds a background stats collector that calculates `UsageNanoCores` for containers and pod sandboxes.

- run in the background every second to collect CPU metrics for all containers and sandboxes (similar to what cAdvisor does)
- keep a rolling buffer of CPU samples and calculates the instantaneous CPU usage rate from consecutive samples
- read pod-level CPU stats from the parent cgroup rather than the pause container
- add cgroupv2 Pressure Stall Information for CPU, memory, and IO
- add missing `Timestamp` and `Interfaces` fields

when Kubernetes runs with `PodAndContainerStatsFromCRI=true`, it expects `UsageNanoCores` to be set in stats responses.
This value represents how much CPU is being used right now (as opposed to `UsageCoreNanoSeconds` which is cumulative).
To calculate it, we need to compare CPU samples over time to replicate what is in cadvisor.

we can't yet really test this in CI as some changes in kubernetes has to land for `--feature-gates=PodAndContainerStatsFromCRI=true`

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2025-12-08 16:03:06 -05:00
Davanum Srinivas
08b02ea0e3 Merge pull request #12594 from monogon/list-pod-sandbox-metrics
fix: refactor ListPodSandboxMetrics
2025-12-04 16:16:28 +00:00
Tim Windelschmidt
398154199a fix: refactor ListPodSandboxMetrics
The original implementation provided a lot of unfilled or wrong
filled metrics. This tries to do better by only setting things I
am fairly certain are correct.

Signed-off-by: Tim Windelschmidt <tim@monogon.tech>
Co-authored-by: Mike Brown <brownwm@us.ibm.com>
2025-12-03 09:33:37 +01:00
Krisztian Litkey
3a717c1756 cri/nri: short-circuit nil adjustment.
Skip processing early if we get a nil adjustment from NRI.

Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
2025-11-27 16:41:29 +02:00
Akihiro Suda
8fa9f4aeb8 Merge pull request #12491 from andrey-noskov/fix-sas-token-leak
fix: redact all query parameters in CRI error logs
2025-11-19 21:46:59 +00:00
Andrey Noskov
3e2cee2bf1 fix: redact all query parameters in CRI error logs
Signed-off-by: Andrey Noskov <andreyn@microsoft.com>
2025-11-19 11:13:47 +01:00
You Binhao
6b82f034de 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>
2025-11-06 20:07:26 +08:00
wheat2018
a0d0f0ef68 fix goroutine leak of container Attach
The monitor goroutine (runs (*ContainerIO).Attach.func1) of Attach will
never finish if it attaches to a container without any stdout or stderr
output. Wait for http context cancel and break the pipe actively to
address the issue.

Signed-off-by: wheat2018 <1151937289@qq.com>
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2025-11-04 16:02:02 +09:00