Commit Graph

1259 Commits

Author SHA1 Message Date
Derek McGowan
223f67ccdb
Merge pull request #7601 from kzys/cgroups-upgrade
Upgrade github.com/containerd/cgroups from v1 to v3
2022-11-17 21:55:03 -08:00
Phil Estes
344da9edb2
Merge pull request #7670 from yanggangtony/fix-desc-for-containerd
complement sub-command note for containerd-main
2022-11-16 10:16:56 -05:00
yanggang
405024db0a
complement sub-command note for containerd-main
Signed-off-by: yanggang <gang.yang@daocloud.io>
2022-11-15 17:04:02 +08:00
yanggang
3abcfb5c07
keep the lower case letter for flag info
Signed-off-by: yanggang <gang.yang@daocloud.io>
2022-11-15 14:09:55 +08:00
Kazuyoshi Kato
8bb5999738 Remove the outdated comment
While containerd/cgroups is only for Linux, the metrics subcommand works
on Windows.

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
2022-11-14 21:07:48 +00:00
Kazuyoshi Kato
dd86128e0d Convert hcsshim's stats to cgroups' stats
Since hcsshim still uses containerd/cgroups 1.x which uses
gogo/protobuf.

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
2022-11-14 21:07:48 +00:00
Fu Wei
9fffa8c712
Merge pull request #7629 from wzshiming/feat/pprof-debug
Add `--debug` args to all subcommands of `ctr pprof`
2022-11-11 11:47:57 +08:00
Shiming Zhang
91e295d766 Add --debug args
Signed-off-by: Shiming Zhang <wzshiming@foxmail.com>
2022-11-09 17:43:53 +08:00
Sebastiaan van Stijn
eaedadbed0
replace strings.Split(N) for strings.Cut() or alternatives
Go 1.18 and up now provides a strings.Cut() which is better suited for
splitting key/value pairs (and similar constructs), and performs better:

```go
func BenchmarkSplit(b *testing.B) {
        b.ReportAllocs()
        data := []string{"12hello=world", "12hello=", "12=hello", "12hello"}
        for i := 0; i < b.N; i++ {
                for _, s := range data {
                        _ = strings.SplitN(s, "=", 2)[0]
                }
        }
}

func BenchmarkCut(b *testing.B) {
        b.ReportAllocs()
        data := []string{"12hello=world", "12hello=", "12=hello", "12hello"}
        for i := 0; i < b.N; i++ {
                for _, s := range data {
                        _, _, _ = strings.Cut(s, "=")
                }
        }
}
```

    BenchmarkSplit
    BenchmarkSplit-10            8244206               128.0 ns/op           128 B/op          4 allocs/op
    BenchmarkCut
    BenchmarkCut-10             54411998                21.80 ns/op            0 B/op          0 allocs/op

While looking at occurrences of `strings.Split()`, I also updated some for alternatives,
or added some constraints; for cases where an specific number of items is expected, I used `strings.SplitN()`
with a suitable limit. This prevents (theoretical) unlimited splits.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-11-07 10:02:25 +01:00
Akihiro Suda
11a06c1a3d
ctr: add ctr content fetch-blob
e.g., `ctr content fetch-blob docker.io/library/debian:latest sha256:43d28810c1b4c28a1be3bac8e0e40fcc472b2bfcfcda952544ed99cb874d2b1a`

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2022-11-04 11:41:11 +09:00
Derek McGowan
49f96d8f7d
Merge pull request #7615 from turan18/export-bug
ctr export strictly matching
2022-11-02 14:36:56 -07:00
Maksym Pavlenko
9c2a634408 Fix ctr crash when pulling with http-trace and http-dump
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-11-01 16:28:39 -07:00
Yasin Turan
78ac0046a7 ctr export strictly match default platform
Signed-off-by: Yasin Turan <turyasin@amazon.com>
2022-11-01 17:35:30 +00:00
Mike Brown
3ce301ddee
Merge pull request #7349 from thaJeztah/gofmt_119
clean-up "nolint" comments, remove unused ones, update golangci-lint
2022-10-17 10:50:24 -05:00
Samuel Karp
6333c751ce
Merge pull request #7519 from Iceber/fix_flags 2022-10-13 11:21:17 -07:00
Iceber Gu
48daccb4dd fix the --no-pivot flag being ignored by ctr tasks start
Signed-off-by: Iceber Gu <wei.cai-nat@daocloud.io>
2022-10-13 11:50:26 +08:00
Sebastiaan van Stijn
752bff981a
cmd/containerd: use golang.org/x/sys/windows.SetStdHandle()
golang.org/x/sys/windows now implements this, so we can use that
instead of a local implementation.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-12 19:33:34 +02:00
Sebastiaan van Stijn
3ebeb6d79b
linting: address gosec G112/G114
GOGC=75 golangci-lint run
    services/server/server.go:320:27: G114: Use of net/http serve function that has no support for setting timeouts (gosec)
        return trapClosedConnErr(http.Serve(l, m))
                                 ^
    services/server/server.go:340:27: G114: Use of net/http serve function that has no support for setting timeouts (gosec)
        return trapClosedConnErr(http.Serve(l, m))
                                 ^
    cmd/containerd-stress/main.go:238:13: G114: Use of net/http serve function that has no support for setting timeouts (gosec)
            if err := http.ListenAndServe(c.Metrics, metrics.Handler()); err != nil {
                      ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-12 14:40:11 +02:00
Sebastiaan van Stijn
634bf0dd31
cmd/containerd: use golang.org/x/sys Service.SetRecoveryActions()
This is the equivalent of the local implementation.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-12 09:43:10 +02:00
Phil Estes
32aa33a9f4
Merge pull request #7497 from thaJeztah/replace_IsAnInteractiveSession
cmd/containerd: replace deprecated windows.IsAnInteractiveSession()
2022-10-11 13:17:48 -07:00
Phil Estes
cef99bea26
Merge pull request #7478 from AkihiroSuda/archive-whiteout-source-date-epoch
archive: add WithSourceDateEpoch() for whiteouts
2022-10-10 15:45:25 -07:00
Samuel Karp
5530a00f39
Merge pull request #7425 from Jenkins-J/ctr-dev-import 2022-10-10 00:56:01 -07:00
Sebastiaan van Stijn
8fc68db0c0
cmd/containerd: replace deprecated windows.IsAnInteractiveSession()
The `IsAnInteractiveSession` was deprecated, and `IsWindowsService` is marked
as the recommended replacement.

For details, see 280f808b4a

> CL 244958 includes isWindowsService function that determines if a
> process is running as a service. The code of the function is based on
> public .Net implementation.
>
> IsAnInteractiveSession function implements similar functionality, but
> is based on an old Stackoverflow post., which is not as authoritative
> as code written by Microsoft for their official product.
>
> This change copies CL 244958 isWindowsService function into svc package
> and makes it public. The intention is that future users will prefer
> IsWindowsService to IsAnInteractiveSession.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-08 15:05:59 +02:00
Akihiro Suda
70fbedc217
archive: add WithSourceDateEpoch() for whiteouts
This makes diff archives to be reproducible.

The value is expected to be passed from CLI applications via the $SOUCE_DATE_EPOCH env var.

See https://reproducible-builds.org/docs/source-date-epoch/
for the $SOURCE_DATE_EPOCH specification.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2022-10-08 08:45:03 +09:00
James Jenkins
9d18b57469 Modify WithDiscardUnpackedLayers
Modify the WithDiscardUnpackedLayers function such that it does not
require any parameters.

Signed-off-by: James Jenkins <James.Jenkins@ibm.com>
2022-09-29 10:24:45 -04:00
Daniel Canter
4333e6a6d6 Swap to net.ErrClosed checks for services
In Go 1.16 `net.ErrClosed` was exported, removing the need to check the
exact text of "use of closed network connection". The stdlib's net listeners
are all setup for this to be a reality, but on Windows containerd uses the
the go-winio projects named pipe implementation as the listener for services.
Before version 0.6.0 this project returned a different error named
`ErrPipeListenerClosed` for using a closed pipe, where this error was just
an `errors.New` with the same text as `net.ErrClosed`, so checking against
`net.ErrClosed` wasn't possible.

Starting in 0.6.0 go-winio has that error assigned to `net.ErrClosed` directly
so this *should* be alright to finally change.

Signed-off-by: Daniel Canter <dcanter@microsoft.com>
2022-09-28 18:20:12 -07:00
James Jenkins
2432b54a56 Add new ctr option for discarding unpacked layers
Add a new ctr cli option, allowing the garbage collector to discard any
unpacked layers after importing an image. This new option is
incompatible with the no-unpack ctr import option.

Signed-off-by: James Jenkins <James.Jenkins@ibm.com>
2022-09-23 15:30:33 -04:00
Derek McGowan
5bedf3fca3
Merge pull request #7328 from liubin/add-privileged-without-host-devices
ctr: add privileged-without-host-devices for run command
2022-09-09 20:58:16 -07:00
Derek McGowan
3f3db4021a
Merge pull request #7341 from my-git9/imagepull2
chore: matching the casing of other flags for ctr's pull command
2022-09-09 20:52:36 -07:00
xin.li
b2a7183a83 matching the casing of other flags for ctr's pull command.
Signed-off-by: xin.li <xin.li@daocloud.io>
2022-09-08 22:07:35 +08:00
zounengren
344b25995b delete redundent import alias and and type conversion
Signed-off-by: zounengren <zouyee1989@gmail.com>
2022-08-31 21:36:24 +08:00
bin liu
fdff11def3 ctr: add privileged-without-host-devices for run command
For Kata Containers, starting a privileged container will fail
if passing all host devices to container due to the permission
issue, like the `privileged_without_host_devices` for CRI service,
add a `privileged-without-host-devices` to `ctr run` command will
disable passing all host devices to containers.

Signed-off-by: bin liu <liubin0329@gmail.com>
2022-08-26 15:56:01 +08:00
Samuel Karp
542e4b219d
Merge pull request #6906 from ginglis13/6441-ctr-import 2022-08-23 17:35:40 -07:00
Samuel Karp
f87a1b09fe
Merge pull request #6931 from egernst/cri-stress 2022-08-10 17:59:48 -07:00
Maksym Pavlenko
ca3b9b50fe Run gofmt 1.19
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-08-04 18:18:33 -07:00
Daniel Canter
ee0f2e9064 Change os.Stderr reassign for Windows service
Previously we were reassigning os.Stderr to the panic.log file we create
when getting asked to run Containerd as a Windows service. The panic.log
file was used as a means to easily collect panic stacks as Windows
services don't have regular standard IO, and the usual recommendation
is to either write to the event log or just to a file in the case of
running as a service.

One place where this panic.log flow was biting us was with shim logging,
which is forwarded from the shim and copied to os.Stderr directly which was
causing shim logs to get forwarded to this panic.log file instead of just
panics. We expose an additional `--log-file` flag if you ask to run a
windows service which is the main way you'd get Containerd logs, and with
this change all of the shim logging which would today end up in panic.log
will now also go to this log file.

Signed-off-by: Daniel Canter <dcanter@microsoft.com>
2022-08-01 16:36:41 -07:00
Jonny Stoten
106433b798
Use httputil.DumpRequestOut for dumping client req
httputil.DumpRequest is only for dumping incoming requests on a server.

Signed-off-by: Jonny Stoten <jonny.stoten@docker.com>
2022-07-27 12:36:14 +01:00
Wei Fu
5f9b318e50 bin/ctr,integration: new runc-shim with failpoint
Added new runc shim binary in integration testing.

The shim is named by io.containerd.runc-fp.v1, which allows us to use
additional OCI annotation `io.containerd.runtime.v2.shim.failpoint.*` to
setup shim task API's failpoint. Since the shim can be shared with
multiple container, like what kubernetes pod does, the failpoint will be
initialized during setup the shim server. So, the following the
container's OCI failpoint's annotation will not work.

This commit also updates the ctr tool that we can use `--annotation` to
specify annotations when run container. For example:

```bash
➜  ctr run -d --runtime runc-fp.v1 \
     --annotation "io.containerd.runtime.v2.shim.failpoint.Kill=1*error(sorry)" \
     docker.io/library/alpine:latest testing sleep 1d

➜  ctr t ls
TASK       PID       STATUS
testing    147304    RUNNING

➜  ctr t kill -s SIGKILL testing
ctr: sorry: unknown

➜  ctr t kill -s SIGKILL testing

➜  sudo ctr t ls
TASK       PID       STATUS
testing    147304    STOPPED
```

The runc-fp.v1 shim is based on core runc.v2. We can use it to inject
failpoint during testing complicated or big transcation API, like
kubernetes PodRunPodsandbox.

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2022-07-22 23:25:40 +08:00
Derek McGowan
24aad6dd46
Merge pull request #7182 from HeavenTonight/main
code cleanup
2022-07-20 13:09:10 -07:00
guiyong.ou
628f6ac681 code cleanup
Signed-off-by: guiyong.ou <guiyong.ou@daocloud.io>
2022-07-19 22:46:32 +08:00
Ye Sijun
f77d45e3ba
ctr: support --user for run/create
Signed-off-by: Ye Sijun <junnplus@gmail.com>
2022-07-12 11:53:03 +08:00
zhanghe9702
b8bb33b92d fix can't edit object by using ctr content edit command
Signed-off-by: zhang he <zhanghe9702@163.com>
2022-07-04 11:44:44 +08:00
Kazuyoshi Kato
78c4d3de72
Merge pull request #7087 from kzys/fuzz-less-hacks
Remove hacks around contrib/fuzz
2022-06-28 09:24:37 -07:00
Shiming Zhang
0a240ff811 Fix missing closed HTTP Body
Signed-off-by: Shiming Zhang <wzshiming@foxmail.com>
2022-06-28 14:49:27 +08:00
Kazuyoshi Kato
17f9c3a0ef Move builtins_*.go to cmd/containerd/builtins to make the files reusable
Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
2022-06-27 22:54:25 +00:00
Phil Estes
8fe779faa9
Merge pull request #7098 from ktock/ctr-create-reordering
ctr: Fix `ctr c create` fails to parse arguments
2022-06-27 15:33:50 -04:00
Kohei Tokunaga
fb5b6612a3 ctr: Fix ctr c create fails to parse arguments
Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
2022-06-23 21:52:53 +09:00
Derek McGowan
99e210c50a
Move metadata plugin registration to seperate package
Signed-off-by: Derek McGowan <derek@mcg.dev>
2022-06-22 17:38:41 -07:00
Justin Terry
5cde04bc7c Forward ctr snapshotter flags on Windows
Signed-off-by: Justin Terry <jlterry@amazon.com>
2022-06-21 07:54:30 -07:00
Samuel Karp
6e53ffb105
ctr: add --hostname flag to create, run
Signed-off-by: Samuel Karp <me@samuelkarp.com>
2022-06-20 15:11:44 -07:00