Commit Graph
1701 Commits
Author SHA1 Message Date
Maksym Pavlenko 5c25750dd5 shim: propagate trace context to runc and OCI hooks
runc and the OCI hooks it spawns are separate processes, so the trace
context can not reach them over ttrpc. Inject it into their environment
instead, riding on the request context via go-runc's WithExtraEnv, which
does not race with concurrent requests the way setting it on the shim
process would.

The otelttrpc interceptor extracts that context, so chain it first
explicitly instead of leaving it to plugin initialization order. Also
flush the spans the tracing plugin buffered before the shim exits.

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2026-08-25 11:21:41 -07:00
Phil Estes 5090fb742c Merge pull request #13939 from akhilerm/revert-drop-in-config-version-check
Revert "add check on version of drop in configs"
2026-08-20 13:18:14 +00:00
Akhil Mohan c8da81e49b ensure that the final config version is the higest in the config list
Signed-off-by: Akhil Mohan <akhilerm@gmail.com>
2026-08-11 15:29:37 +05:30
Akhil Mohan a8ed546687 Revert "add check on version of drop in configs"
This reverts commit 21248d0076.

Signed-off-by: Akhil Mohan <akhilerm@gmail.com>
2026-08-11 15:09:27 +05:30
Chris Ayoub 3778cc36f4 ctr: drain exec output before cleanup
Wait for stdout and stderr copying to complete after validating process exit so deferred process deletion does not cancel readers with output still in flight.

Signed-off-by: Chris Ayoub <cayoub@openai.com>
2026-08-09 20:25:31 +00:00
Maksym Pavlenko 7df6bb0a67 erofs: allow multiple layer content cache directories
The layer content cache was a single directory, so every source of
pre-converted blobs had to be merged into one tree. A shared read-only fleet
cache, a host-local cache, and a per-image warm cache could not coexist.

Replace layer_content_cache with layer_content_caches, a list. Each directory
is checked in order and the first hit is staged into the snapshot; a layer
found in none of them falls back to the normal download-and-convert path.

Cache directories are no longer required to exist at startup. A missing one is
indistinguishable from an empty one at lookup time (both are simply a miss),
and it may well be mounted after the daemon starts, so the only check left is
that each path is absolute -- a relative one would be symlinked into the
snapshot dir and dangle.

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2026-08-03 13:14:44 -07:00
Chris Ayoub 0d37ad2683 ctr: register EROFS fsview
ctr resolves named users and groups for run and task exec in the
client process. Since EROFS fsview support moved behind registration,
the ctr application does not link the handler and falls back to a
temporary host mount.

Register the handler with the ctr application so EROFS snapshots can
be inspected directly. Non-EROFS mounts continue through the existing
handlers unchanged.

Signed-off-by: Chris Ayoub <cayoub@openai.com>
2026-08-01 22:01:17 +00:00
Samuel Karp 18a01c0020 ctr: add --scrub-logs flag for Windows
Adds a new --scrub-logs flag to ctr run on Windows. This flag enables
the ScrubLogs option for the io.containerd.runhcs.v1 shim.

Assisted-by: gemini-cli
Signed-off-by: Samuel Karp <samuelkarp@google.com>
2026-07-24 00:07:43 -07:00
Maksym Pavlenko 82a47efe92 Support dmverity
Add a --dmverity flag to `ctr images build-erofs-cache`. When set, each cached
erofs blob is dm-verity formatted (the hash tree is appended in place) and a
.dmverity sidecar is written alongside it. This is required when the erofs
snapshotter runs with dmverity_mode=on, which rejects cache hits that lack a
sidecar; without it such layers would have to be formatted out-of-band.

Extract the differ's dm-verity formatting into a shared dmverity.FormatLayer so
the differ and the cache builder share one implementation; the differ's
formatDmverityLayer now delegates to it.

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2026-07-21 10:07:08 -07:00
Maksym Pavlenko f52e748f16 ctr: add build-erofs-cache to populate the erofs layer cache
Add `ctr images build-erofs-cache <image> <cache_dir>`, which reads an
already-pulled image's layers from the content store, converts each into a
directly-mountable erofs blob, and writes them under
<cache_dir>/<algorithm>/<hex>.erofs keyed by the layer's diffID. This
populates the directory the erofs snapshotter's layer_content_cache reads
on pull; because the key is the source diffID, layers shared across images
converge on one blob. No converted image is produced.

Extract the per-layer uncompress + mkfs.erofs step out of LayerConvertFunc
into an exported ConvertLayerToErofs so the image converter and the cache
builder share a single conversion path.

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2026-07-21 09:43:41 -07:00
Maksym Pavlenko 988f3af07e Merge pull request #13699 from ktock/parentpath
shim: allow specifying runc's --parent-path during checkpointing
2026-07-01 05:46:39 +00:00
Kohei Tokunaga ea0ed51e21 shim: allow specifying runc's --parent-path during checkpointing
Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
2026-07-01 00:13:02 +00:00
Samuel Karp 288f0d99d6 Merge pull request #13667 from anmaxvl/windows-systemtemp-from-toml
Set SystemTemp env var to config temp on Windows
2026-06-30 19:00:41 +00:00
Maksim An faff4d66ba Set SystemTemp env var to config temp on Windows
Since Go 1.21, os.MkdirTemp/os.TempDir resolve the temp directory via
Windows' GetTempPath2W. For processes running as SYSTEM (as containerd
does when running under the SCM), that API reads the temp location from
the SystemTemp environment variable rather than TMP/TEMP. As a result,
the existing TMP/TEMP overrides no longer steer the layer-extraction
tempdir for the containerd service, so it falls back to the default
C:\\Windows\\SystemTemp and unpacks on the SystemDrive, reintroducing the
cross-volume copy the 'temp' config option was meant to avoid.

Set SystemTemp to config.TempDir alongside TEMP/TMP so the override keeps
working on Go 1.21+.

Factor the env-var setting out of CreateTopLevelDirectories into a small
setTempDirEnv helper and add a focused unit test (TestSetTempDirEnv) that
verifies the expected variables are set: TEMP/TMP/SystemTemp on Windows,
TMPDIR on other platforms.

Ref: https://cs.opensource.google/go/go/+/refs/tags/go1.21.0:src/os/file_windows.go
Signed-off-by: Maksim An <maksiman@microsoft.com>
2026-06-25 01:08:02 -07:00
Abhishek Bhunia 125c15bcd0 Register tracing log hook before signal handling
Signed-off-by: Abhishek Bhunia <abhishek.bhunia@docker.com>
2026-06-02 15:40:17 -05:00
Akihiro SudaandClaude Opus 4.7 dbcaa504c6 runc-shim: don't hold the service lock across runc create
The task service guards its containers map with s.mu, and getContainer()
takes it on behalf of effectively every task RPC (State, Connect, Stats,
Wait, Pause, Kill, ...). Create() held s.mu for its whole duration,
including runc.NewContainer(), which runs the actual `runc create`.

`runc create` can be slow on a loaded host. While it runs, any concurrent
task RPC blocks on s.mu. The tasks service applies a 2s timeout to State
(io.containerd.timeout.task.state), so a concurrent State waits on s.mu,
exceeds the deadline, and the ttrpc call is abandoned -- the late shim
reply then shows up as:

    ttrpc: received message on inactive stream stream=3

Since deadline errors are now surfaced to clients, this is treated as a
fatal failure and the just-created container is torn down right after
start (observed on Lima/vz: nginx -> Exited (1)).

Move runc.NewContainer() out of the s.mu critical section, mirroring the
runtime v1 shim lock optimization. s.mu is taken only once the container
exists, to guard the map and the remaining (fast) setup, so a slow create
no longer blocks concurrent State and other lookups.
preStart/handleStarted/cleanup only use s.lifecycleMu, so early-exit
handling is unchanged.

See lima-vm/lima#5030.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2026-05-28 18:02:52 +09:00
Mike BrownandSebastiaan van Stijn 7b1604739f cleanup the systemd debug notification logging
Signed-off-by: Mike Brown <brownwm@us.ibm.com>
Co-authored-by: Sebastiaan van Stijn <github@gone.nl>
2026-05-14 08:36:04 -05:00
Wei Fu ac77917b2f config: preserve legacy grpc address across sparse imports
When migrating v3 [grpc] config to the v4 server plugin config, only
emit fields that were actually set in the legacy config. This prevents
a sparse imported [grpc] section, such as one only setting
max_send_message_size, from generating address = "" and overwriting the
address migrated from the root config.

Add table-driven coverage for sparse legacy grpc imports, including
address preservation, imported address override, and default address
retention when no imported config specifies address.

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2026-04-29 13:13:33 -04:00
Derek McGowan 14fe0ac645 Merge pull request #13052 from delthas/fix-shim-sync
shim: fix send on closed channel race in task service
2026-04-28 02:24:13 +00:00
Davanum Srinivas c30f23452c cri: use upstream Kubernetes modules
Switch the CRI integration layer from containerd's forked Kubernetes helpers
and clients to the upstream Kubernetes modules, and finalize the dependency
update to Kubernetes v0.36.0.

Replace the remaining internal helper copies with upstream packages:
- internal/cri/clock -> k8s.io/utils/clock
- internal/cri/executil -> upstream CRI exec helpers
- internal/cri/resourcequantity -> k8s.io/apimachinery/pkg/api/resource
- internal/cri/setutils -> k8s.io/apimachinery/pkg/util/sets
- internal/cri/types/labels.go -> internal/cri/labels
- integration/cri-api/pkg/apis/services.go -> k8s.io/cri-api/pkg/apis/services.go

Adopt the upstream CRI clients directly:
- add k8s.io/cri-client v0.36.0, k8s.io/cri-streaming v0.36.0, and
  k8s.io/streaming v0.36.0 as direct dependencies
- promote k8s.io/utils to a direct dependency and pull in
  k8s.io/component-base v0.36.0 indirectly
- keep integration/remote as a thin containerd adapter around cri-client,
  because the integration tests still need the stream-shaped
  GetContainerEvents RPC

Finalize the Kubernetes dependency update from v0.36.0-rc.0 to v0.36.0,
refresh vendor/, and drop the obsolete internal utility copies.

Also fix the protobuf MessageState mutex-copy vet failures exposed by the new
APIs and close the temporary integration CRI clients explicitly.

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2026-04-23 12:59:58 +02:00
Fu Wei 46a7bd7acb Merge pull request #12562 from dmcgowan/plugin-api-handlers
Add plugins for server listeners
2026-04-22 17:27:28 +00:00
Derek McGowan a0f3c53e2f Ensure Plugins is not nil during migration
Signed-off-by: Derek McGowan <derek@mcg.dev>
2026-04-21 18:02:41 -07:00
Derek McGowan 841c518a22 Add tests for serviceMigrate config migration
Signed-off-by: Derek McGowan <derek@mcg.dev>
2026-04-21 18:02:41 -07:00
Derek McGowan a2b19072b8 Add metrics server plugin
Signed-off-by: Derek McGowan <derek@mcg.dev>
2026-04-21 18:02:40 -07:00
Derek McGowan c15ec24857 Add server plugins for grpc and ttrpc
Migrate configuration and move server initialization

Signed-off-by: Derek McGowan <derek@mcg.dev>
2026-04-21 18:02:40 -07:00
Derek McGowan 06c23567c0 Add new server plugin type use for debug server
The new server plugin type allows services which have listeners to be
configured as plugins rather than defined directly in the global
configuration. This provides more configuration consistency and allows
containerd to be extended for new types of api handlers.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2026-04-21 18:02:00 -07:00
Akihiro Suda 341401c1d5 Merge pull request #12785 from dmcgowan/pass-socket-address
Make shim socket directory use configured directory
2026-04-15 10:24:25 +00:00
Derek McGowan 59c3464a01 Remove the unnecessary mkdir on the default state directory
The default state directory does not need to be created and only the
configured state directory must be setup.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2026-04-15 00:21:18 -07:00
Derek McGowan d806373feb Make shim socket directory use configured state
Send the socket directory from containerd to the shim. The shim still
decides where the socket goes but can use the environment variable
passed from containerd to ensure the socket is placed in the configured
directory with proper permission.

This is needed for some rootless cases which do not have permission to
the default state directory as currently set. The directory being
hardcoded by the shim means it is currently not possible to change the
location the shim will listen at.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2026-04-15 00:21:18 -07:00
ChengyuZhu6 64a2e62b52 erofs: wire os.features into conversion and selection
Mark converted EROFS manifests with the erofs OS feature and cover
feature-aware manifest selection and unpack routing for erofs images.

Signed-off-by: ChengyuZhu6 <hudson@cyzhu.com>
2026-04-15 10:28:54 +08:00
ChengyuZhu6 b320d3c855 ctr: add EROFS image conversion support
Add EROFS conversion support to ctr convert command with configurable
options for tar-index mode and mkfs parameters.

Usage:
  ctr image convert --erofs src:tag dst:tag
  ctr image convert --erofs --erofs-compression='lz4hc,12' src:tag dst:tag

Signed-off-by: ChengyuZhu6 <hudson@cyzhu.com>
2026-04-15 10:28:47 +08:00
Derek McGowan 2c102c6cbe Update bootstrap API log level definition
Avoid using logrus concepts in the API, use slog style log levels with
integer values and 0 meaning the default "info" level.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2026-04-10 15:23:34 -07:00
Derek McGowan a755ca16e5 Merge pull request #12865 from dmcgowan/readonly-overlay-erofs-no-mount
Support reading readonly overlays without mounting
2026-04-09 18:37:15 +00:00
Maksym Pavlenko 16b7ce2549 Address code review suggestions
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2026-04-08 08:29:28 -05:00
Maksym Pavlenko 9bf65dcf02 Use enums instead of strings for capabilities and log level
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2026-04-08 08:29:28 -05:00
Derek McGowan 243cab594e Deprecate old pkg/shim interfaces
Signed-off-by: Derek McGowan <derek@mcg.dev>
2026-04-08 08:29:28 -05:00
Maksym Pavlenko eea1fa6516 Do not fail when failed to parse log level
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2026-04-08 08:29:28 -05:00
Maksym Pavlenko 0f55bdd49c Fix extensions API and update tests
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2026-04-08 08:29:28 -05:00
Maksym Pavlenko 58022a748a Parse log level when starting shim instance
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2026-04-08 08:29:28 -05:00
Maksym Pavlenko d957b1bf53 Use log level instead of debug flag
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2026-04-08 08:29:28 -05:00
Maksym Pavlenko 9e9a095feb Read spec annotations from file
Revert changes related to reading annotations in runc v2 shim,
because this requires a special path for runc shim. This complicates
migration to the new bootstrap API.

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2026-04-08 08:29:28 -05:00
Maksym Pavlenko 5ea993b48d Pass runc options as a separate extension
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2026-04-08 08:29:28 -05:00
Maksym Pavlenko 7f39b2d933 Update shim to support new bootstrap api
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2026-04-08 08:29:28 -05:00
Jintao Zhang cf772973cf process/io: ignore SIGTERM exit in cancel() to fix flaky test
When cancel() sends SIGTERM to a short-lived logging binary that is
already mid-exit, cmd.Wait() may return 'signal: terminated'. This is
expected behavior since we sent the SIGTERM ourselves, so treat it as
a normal exit.

Fixes flaky TestNewBinaryIOBinaryV2Ready.

Signed-off-by: Jintao Zhang <zhangjintao9020@gmail.com>
2026-04-05 13:41:54 +00:00
Jintao Zhang 22e6e1541c Add binary-v2 logging readiness scheme
Expose log URI schemes in runtime v2 metadata

Signed-off-by: Jintao Zhang <zhangjintao9020@gmail.com>
2026-04-05 13:41:15 +00:00
Derek McGowan 21d666cfbc Update fsview to allow type registration
Move erofs implementation to plugin and register with fsview.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2026-04-04 22:37:38 -07:00
Maksym Pavlenko 43d906b6ff Merge pull request #13117 from HASidd/log-trace
tracing: add option to inject trace ID into logrus fields
2026-03-31 23:44:09 +00:00
Hasan Siddiqui 10c30fb74a tracing: add option to inject trace ID into logrus fields
Introduce functional options to NewLogrusHook to allow optional Trace ID
injection into log fields. This enables log-trace correlation via the
[debug] config without breaking existing external consumers of
pkg/tracing.

Signed-off-by: Hasan Siddiqui <hasiddiqui@google.com>
2026-03-24 21:51:27 +00:00
Hasan Siddiqui dc5806cd94 Propagate OpenTelemetry traces in outgoing RPCs from plugin clients
While incoming gRPC requests are already being traced via the
server-side handler, outgoing RPCs to proxy plugins are missing the
client-side equivalent. Adding otelgrpc.NewClientHandler() ensures trace
context is successfully propagated to the plugins.

Signed-off-by: Hasan Siddiqui <hasiddiqui@google.com>
2026-03-24 01:57:46 +00:00
Weixie Cui ee7441ddfc runc-shim: fix exec PID error message and fmt verb
Correct the typo in the error string (pi -> pid) and use %w for error wrapping instead of the invalid %wd verb when reading the exec PID file.

Signed-off-by: Weixie Cui <cuiweixie@gmail.com>
2026-03-22 20:27:44 +08:00