Commit Graph

932 Commits

Author SHA1 Message Date
Evan Lezar
f5cd8d56f4 Map ctr --gpus requests to NVIDIA CDI device requests
This change maps ctr --gpus requests to CDI device requests.
This is done by mapping --gpus ID to a nvidia.com/gpu=ID device
request.

This removes the dependence on the nvidia-container-cli and instead
uses existing CDI specifications for nvidia devices if available on
the system.

Signed-off-by: Evan Lezar <elezar@nvidia.com>
2025-11-25 11:22:22 +01:00
Maksym Pavlenko
4c32f5f73b Merge pull request #12531 from samuelkarp/ctr-dump-config
ctr run: dump OCI config to a file
2025-11-18 18:43:48 +00:00
Maksym Pavlenko
a1a6229699 Merge pull request #12532 from samuelkarp/ctr-rlimit-nofile
ctr: allow rlimit-nofile override
2025-11-18 18:41:13 +00:00
Derek McGowan
c2b22d6bd6 Update the ctr pull defaults when using the transfer service
Match the defaults set by the transfer service which will configure
linux by default on darwin hosts.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-11-18 08:51:51 -08:00
Samuel Karp
ee1f94e4d1 ctr: allow rlimit-nofile override
Signed-off-by: Samuel Karp <samuelkarp@google.com>
2025-11-17 21:50:12 -08:00
Samuel Karp
3b899aa111 ctr run: dump OCI config to a file
Signed-off-by: Samuel Karp <samuelkarp@google.com>
2025-11-17 15:39:21 -08:00
Wei Fu
2042e805b8 cri/server/podsandbox: disable event subscriber
We have individual goroutine for each sandbox container. If there is any
error in handler, that goroutine will put event in that backoff queue.
So we don't need event subscriber for podsandbox. Otherwise, there will
be two goroutines to cleanup sandbox container.

```
>>>> From EventMonitor
  time="2025-10-23T19:30:59.626254404Z" level=debug msg="Received containerd event timestamp - 2025-10-23 19:30:59.624494674 +0000 UTC, namespace - \"k8s.io\", topic - \"/tasks/exit\""
  time="2025-10-23T19:30:59.626301912Z" level=debug msg="TaskExit event in podsandbox handler container_id:\"22e15114133e4d461ab380654fb76f3e73d3e0323989c422fa17882762979ccf\" id:\"22e15114133e4d461ab380654fb76f3e73d3e0323989c422fa17882762979ccf\" pid:203121 exit_status:137 exited_at:{seconds:1761247859 nanos:624467824}"

>>> If EventMonitor handles task exit well, it will close ttrpc
connection and then waitSandboxExit could encounter ttrpc-closed error

  time="2025-10-23T19:30:59.688031150Z" level=error msg="failed to delete task" error="ttrpc: closed" id=22e15114133e4d461ab380654fb76f3e73d3e0323989c422fa17882762979ccf
```

If both task.Delete calls fail but the shim has already been shut down, it
could trigger a new task.Exit event sent by cleanupAfterDeadShim. This would
result in three events in the EventMonitor's backoff queue, which is unnecessary
and could cause confusion due to duplicate events.

The worst-case scenario caused by two concurrent task.Delete calls is a shim
leak. The timeline for this scenario is as follows:

| Timestamp | Component       | Action                        | Result                                                                                           |
| ------    | -----------     | --------                      | --------                                                                                         |
| T1        | EventMonitor    | Sends `task.Delete`           | Marked as Req-1                                                                                  |
| T2        | waitSandboxExit | Sends `task.Delete`           | Marked as Req-2                                                                                  |
| T3        | containerd-shim | Handles Req-2                 | Container transitions from stopped to deleted                                                    |
| T4        | containerd-shim | Handles Req-1                 | Fails - container already deleted<br>Returns error: `cannot delete a deleted process: not found` |
| T5        | EventMonitor    | Receives `not found` error    | -                                                                                                |
| T6        | EventMonitor    | Sends `shim.Shutdown` request | No-op (active container record still exists)                                                     |
| T7        | EventMonitor    | Closes ttrpc connection       | Clean container state dir                                                                        |
| T8        | containerd-shim | Handles Req-2                 | Removes container record from memory                                                             |
| T9        | waitSandboxExit | Receives error                | Error: `ttrpc: closed`                                                                           |
| T10       | waitSandboxExit | Sends `shim.Shutdown` request | Fails (connection already closed)                                                                |
| T11       | waitSandboxExit | Closes ttrpc connection       | No-op (already closed)                                                                           |

The containerd-shim is still running because shim.Shutdown was sent at T6
before T8. Because container's state dir is deleted at T7, it's unable to clean
it up after containerd restarted.

We should avoid concurrent task.Delete calls here.

I also add subcommand - shutdown - in `ctr shim` for debug.

Fixed: #12344

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2025-10-24 12:19:52 -04:00
Derek McGowan
2a8d301177 Set default run platform in ctr
Currently run will generate invalid specifications on non-Linux Unix
platforms. Linux should be the default container platform for run when
the platform is not explicitly provided.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-10-15 17:06:39 -07:00
Derek McGowan
49634889f8 Update ctr image mounts to use mount manager
Updates the image mounts to use temporary mounts and no longer require
passing in a target directory.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-09-29 17:08:33 -07:00
Derek McGowan
62062902f5 Add support for mount manager to ctr snapshots mount
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-09-29 17:08:33 -07:00
Derek McGowan
479cf42ca2 Add extraction progress to transfer service
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-09-10 20:07:40 -07:00
Chenyang Yan
bd9e577c26 Fix ctr snapshot mount produce invalid mount command for empty option
snapshotter.Mounts() maybe get empty Options for different snapshot service.

Empty Options will produce invalid mount command from printMounts:
```
$ ctr -n flintlock snapshot --snapshotter devmapper mount /mnt flintlock/flintlock/demo-2/01K24ZRN9EFAVQVNGXQS26BYVG/root
mount -t ext4 /dev/mapper/fc-dev-thinpool-snap-19 /mnt -o
$ cmd=$(ctr -n flintlock snapshot --snapshotter devmapper mount /mnt flintlock/flintlock/demo-2/01K24ZRN9EFAVQVNGXQS26BYVG/root)
$ $cmd
mount: option requires an argument -- 'o'
Try 'mount --help' for more information.
```

Signed-off-by: Chenyang Yan <memory.yancy@gmail.com>
2025-08-09 15:06:07 +08:00
Sebastiaan van Stijn
ed174c9145 cmd/ctr: rename vars that shadowed builtin
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-21 09:36:22 +02:00
Akihiro Suda
d455980d36 Merge pull request #12017 from caoruidong/sandbox_info_com
ctr:add sandbox info command to print sandbox info
2025-07-09 10:15:49 +00:00
Ruidong Cao
b671a97213 ctr:add sandbox info command to print sandbox info
Signed-off-by: Ruidong Cao <caoruidong.crd@alibaba-inc.com>
2025-06-24 15:53:04 +08:00
yashsingh74
b3eec6d8e9 fix: ST1005: error strings should not end with punctuation or newlines
Signed-off-by: yashsingh74 <yashsingh1774@gmail.com>
2025-06-18 14:16:41 +05:30
ningmingxiao
9ae54175dd ctr:make sure containerd socket exist before create client
Signed-off-by: ningmingxiao <ning.mingxiao@zte.com.cn>
2025-05-07 14:17:00 +08:00
Samuel Karp
6d4c30b2ce Merge pull request #11728 from samuelkarp/ctr-shim-address
ctr shim: allow override to computed shim address
2025-04-28 20:48:55 +00:00
Fu Wei
ef7bdf18a1 Merge pull request #10177 from azr/azr/parallel-layer-fetch
Multipart layer fetch
2025-04-24 20:35:00 +00:00
Adrien Delorme
024775dab1 set dl options on resolver
Signed-off-by: Adrien Delorme <azr@users.noreply.github.com>
2025-04-24 11:41:33 +02:00
Adrien Delorme
88116b1911 remove max_dl_operations setting
Signed-off-by: Adrien Delorme <azr@users.noreply.github.com>
2025-04-24 11:39:42 +02:00
Adrien Delorme
f9af08820b perf(pull): multipart layer fetch
Signed-off-by: Adrien Delorme <azr@users.noreply.github.com>
Co-Authored-By: Corentin REGAL <143578+co42@users.noreply.github.com>
2025-04-24 11:39:42 +02:00
Maksym Pavlenko
17b6e1ef85 Allow streaming to client
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2025-04-23 18:03:29 -07:00
Maksym Pavlenko
bd8e6c727d Enable http debug and tracing for non local puller
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2025-04-23 17:39:57 -07:00
Maksym Pavlenko
27e6c117d9 Move HTTP debug code to pkg
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2025-04-23 17:38:47 -07:00
Samuel Karp
f512e31743 ctr shim: allow override to computed shim address
The default computed address follows the format used by the
io.containerd.runc.v2 shim, but there is no requirement that third-party
shims follow the same format.  The new --shim-address option allows
debugging of third-party shims with a different address format.

Signed-off-by: Samuel Karp <samuelkarp@google.com>
2025-04-22 11:25:23 -07:00
Akihiro Suda
d9c889568e Remove the support for Schema 1 images
Schema 1 (`application/vnd.docker.distribution.manifest.v1+prettyjws`) has been
officially deprecated since containerd v1.7 (PR 6884), and disabled since v2.0 (PR 9765).

Users who have been seeing warnings like `conversion from schema 1 images is deprecated`
now have to rebuild the image with Schema 2 or OCI.

Schema 2 was introduced in Docker 1.10 (Feb 2016), so most users should have been already
using Schema 2 or OCI.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2025-04-11 09:03:26 +09:00
Phil Estes
98af40b752 Merge pull request #10722 from henry118/uidmap2
Support multiple uid/gid mappings [2/2]
2025-01-17 18:34:40 +00:00
Akihiro Suda
04bac22dfc Merge pull request #11262 from dmcgowan/fix-cdi-oci-opt
Move CDI device spec out of the OCI package
2025-01-14 07:27:22 +00:00
Derek McGowan
e20f7f4a24 Move CDI device spec out of the OCI package
The CDI device injection spec opt was mistakenly added to the OCI
package which brought in an unintended dependency on CDI and its
transitive dependencies.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-01-13 21:59:59 -08:00
luchenhan
740c5d4284 docs: fix some function names in comment
Signed-off-by: luchenhan <hanluchen@aliyun.com>
2025-01-14 11:36:35 +08:00
Akihiro Suda
79a42eedc7 ctr: ctr images import --all-platforms: fix unpack
Fix issue 11228

`ctr images import --all-platforms` w/o `--local` was failing due to
`unable to initialize unpacker: no unpack platforms defined` error.

W/ `--local`, it unpacks the layers for the strict-default platform.

Now `ctr images import --all-platforms` w/o `--local` unpacks the layers
for the non-strict default platform.
This behavior still differs from `--local`.
i.e., on an arm64 host, arm/v{5,6,7} layers are unpacked too.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2025-01-08 10:30:49 +09:00
Maksym Pavlenko
ff4f5cbff0 Merge pull request #11118 from tboevil/ctr-syncfs
cmd/ctr: allow user to syncfs during unpacking image locally
2024-12-11 19:16:06 +00:00
Henry Wang
ec231cdcf2 Update ctr to support remapper labels with multiple uid/gid mapping entries
Signed-off-by: Henry Wang <henwang@amazon.com>
2024-12-11 18:04:11 +00:00
Qiyuan Liang
11b78255de cmd: add syncfs option to ctr command
Signed-off-by: Qiyuan Liang <qiyuan.liang@smartx.com>
2024-12-09 13:14:28 +08:00
Jin Dong
4c11d753ca ctr pull unpack for default platform using transfer service
Signed-off-by: Jin Dong <djdongjin95@gmail.com>
2024-12-03 06:35:22 +00:00
Henry Wang
83aaa89b61 update ctr run to support multiple uid/gid mappings
Signed-off-by: Henry Wang <henwang@amazon.com>
2024-09-10 17:06:27 +00:00
Jin Dong
35b0292572 remove sha256-simd
Signed-off-by: Jin Dong <djdongjin95@gmail.com>
2024-08-25 04:46:04 +00:00
Fu Wei
dd2a24cf0e Merge pull request #10557 from tariq1890/cli-ctx-add
use ctx object from cliContext instead of a creating a new one
2024-08-13 01:13:48 +00:00
Samuel Karp
7d4da0cb28 ctr: shim state query for old shims
Old shims do not implement containerd.task.v3.Task, but it can be
useful to use a new ctr with an older shim especially during upgrade
scenarios.

Signed-off-by: Samuel Karp <samuelkarp@google.com>
2024-08-07 16:48:14 -07:00
Samuel Karp
d59e8a8404 ctr: shim state for secondary tasks
The v2 shim interface supports grouping, so a single shim can manage
multiple tasks.  Prior to this change, the `shim state` command could
only query the state of the primary task (task that shares the same ID
as the shim).

Signed-off-by: Samuel Karp <samuelkarp@google.com>
2024-08-07 16:48:08 -07:00
Tariq Ibrahim
32c2d14932 use ctx object from cliContext instead of a creating a new one
Signed-off-by: Tariq Ibrahim <tibrahim@nvidia.com>
2024-08-06 13:42:22 -07:00
Danny Canter
b41bb6df73 Avoid potential reallocs by pre-sizing some slices
There's a couple spots where we know exactly how large
the destination buffer should be, so pre-size these to
avoid any reallocs to a higher capacity.

Signed-off-by: Danny Canter <danny@dcantah.dev>
2024-07-19 13:05:49 -07:00
Henry Wang
243b803a19 Add pprof to runc-shim
Signed-off-by: Henry Wang <henwang@amazon.com>
2024-06-20 23:12:31 +00:00
Sebastiaan van Stijn
dd0542f7c1 cmd: don't alias context package, and use cliContext for cli.Context
Unfortunately, this is a rather large diff, but perhaps worth a one-time
"rip off the bandaid" for v2. This patch removes the use of "gocontext"
as alias for stdLib's "context", and uses "cliContext" for uses of
cli.context.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-20 02:15:13 +02:00
Akihiro Suda
86b8a88241 Remove pkg/seed
Since Go 1.20, math/rand does not need explicit seeding:
https://go.dev/doc/go1.20#minor_library_changes

Go <= 1.19 is no longer supported due to EOL.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2024-06-13 08:50:28 +09:00
Kohei Tokunaga
df7f6ba5b9 ctr: return explicit errors for flags unsupported by transfer service
ctr currently silently ignores several flags by default (without --local) and
the user can't know which flags are supported until they see the code.
This commit fixes ctr to return an explicit error when it finds an unsupported
flag.

Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
2024-06-11 12:08:47 +09:00
Maksym Pavlenko
34d3c17ae2 Merge pull request #10291 from ktock/push-platform-conf
Transfer: Push: Enable to specify platforms
2024-06-05 21:28:09 +00:00
Kohei Tokunaga
cde2527fce ctr: pull: Do not ignore labels when transfer service is used
Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
2024-06-05 12:26:00 +09:00
Kohei Tokunaga
5611fdd4af Transfer: Push: Enable to specify platforms
Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
2024-06-04 10:02:13 +09:00