Commit Graph

946 Commits

Author SHA1 Message Date
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
Sebastiaan van Stijn
a122afe13b cmd: modernize: any
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-03-17 13:36:16 +01:00
Derek McGowan
489b653034 Merge pull request #13022 from thaJeztah/modernize
*: modernize code
2026-03-16 22:23:04 +00:00
Sebastiaan van Stijn
29030ff927 cmd: modernize: any
go install golang.org/x/tools/go/analysis/passes/modernize/cmd/modernize@latest
    modernize -any -fix ./...

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-03-15 18:24:14 +01:00
Sebastiaan van Stijn
09f7154dbd *: modernize: mapsloop
go install golang.org/x/tools/go/analysis/passes/modernize/cmd/modernize@latest
    modernize -mapsloop -fix ./...

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-03-15 15:01:38 +01:00
majianhan
aa600f65dd fix: correct typos found by codespell
Fix various typos across source code, tests, and documentation:
- README.md: Preforming → Performing
- pull.go: commpleted → completed
- server_test.go: unxpected → unexpected
- diff.go: atleast → at least
- content.go: desciptor → descriptor
- remote.go: requst → request
- imagestore_test.go: expeceted → expected
- pull_test.go: shoule → should

Signed-off-by: majianhan <majianhan@kylinos.cn>
2026-03-12 08:54:56 +08:00
majianhan
01d094d663 docs: update outdated content fetch help text
The 'content fetch' command description has been unchanged since it was
first added over 8 years ago. It described the feature as "experimental"
with "few leaps to make this work", which no longer reflects reality.

Update the help text to accurately describe what the command does: it
pulls image content into the content store without unpacking, and can
be used to pre-fetch images.

Fixes #11754

Signed-off-by: Crawford Ma <crawfordxx@users.noreply.github.com>
2026-03-11 20:20:20 +08:00
Maksym Pavlenko
f4681e01d0 Merge pull request #12839 from shiv-tyagi/vendor-discovery-gpus
Detect vendor in cdi specs to generate deviceIDs for --gpus
2026-02-20 04:13:12 +00:00
Shiv Tyagi
090def0567 Remove vendor lister and update tests
Signed-off-by: Shiv Tyagi <Shiv.Tyagi@amd.com>
2026-02-19 09:28:50 -06:00
Shiv Tyagi
7035fe813d Add unit tests for gpuDeviceNames anddetectGPUVendor
Signed-off-by: Shiv Tyagi <Shiv.Tyagi@amd.com>
2026-02-19 09:28:50 -06:00
Shiv Tyagi
ab1a24989f Detect vendor in cdi specs to generate deviceIDs for --gpus
This adds GPU vendor auto-detection from CDI specs instead of hardcoding nvidia.com.
This allows the --gpus flag to work with both NVIDIA and AMD GPUs by detecting the vendor from available CDI spec files.

Signed-off-by: Shiv Tyagi <Shiv.Tyagi@amd.com>
2026-02-19 09:28:50 -06:00
Sebastiaan van Stijn
5fde7662f1 cmd/*: don't print default value for '--help' and '--version'
Remove the confusing `(default: false)` that's printed.

Before this:

    ctr --help | tail -n2
       --help, -h                   Show help (default: false)
       --version, -v                Print the version (default: false)

After this:

    ctr --help | tail -n2
       --help, -h                   Show help
       --version, -v                Print the version

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-02-07 13:10:13 +01:00
Maksym Pavlenko
992597bfe9 Fix TTRPC prefix
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2026-01-15 13:06:50 -08:00
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