Commit Graph

344 Commits

Author SHA1 Message Date
Kazuyoshi Kato
6596a70861 Use github.com/containerd/cgroups/v3 to remove gogo
Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
2022-11-14 21:07:48 +00:00
Maksym Pavlenko
3a9044f240 Rename darwin-kubelet to containerd
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-11-07 22:58:25 -08:00
Maksym Pavlenko
525fe21e22
Merge pull request #7604 from wzshiming/fix/close-fifo
Fix missing closed fifo
2022-11-03 20:55:28 -07:00
Shiming Zhang
c607f83c38 Fix missing closed fifo
Signed-off-by: Shiming Zhang <wzshiming@foxmail.com>
2022-11-04 10:13:47 +08:00
Maksym Pavlenko
2da7824683 Add sequence diagram for shim runtime v2
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-10-31 15:45:28 -07:00
Maksym Pavlenko
b7d0d12715 Cleanup sandbox interfaces
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-10-25 12:31:32 -04:00
Phil Estes
d7ea7de900
Merge pull request #7534 from mxpv/shim
Don't unmount on Darwin when deleting bundle
2022-10-17 08:27:05 -07:00
Maksym Pavlenko
fb6a40dc9d Don't unmount on Darwin when deleting bundle
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-10-14 14:35:24 -07:00
Kazuyoshi Kato
49a54e23cb Stats() shouldn't assume s.container is non-nil
Like other exported methods, Stats() shouldn't assume s.container is
non-nil.

Fixes #7468.

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
2022-10-12 22:11:49 +00: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
Maksym Pavlenko
1d8b1bc75b Cleanup shim manager
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-08-11 21:41:32 -07:00
Maksym Pavlenko
ff65fc2d0e Make TaskList generic
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-08-10 14:02:53 -07:00
Brian Goff
f5fb2c32d2 Regenerate protos with updated protoc-gen-go
This fixes CI issues

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2022-07-28 16:59:30 +00:00
Wei Fu
b297775eaf runtime/v2/shim: return if error in load plugin
If there is any unskipable error during setuping shim plugins, we should
fail return error to prevent from leaky shim instance. For example,
there is error during init task plugin, the shim ttrpc server will not
contain any shim API method. The any call to the shim will receive that

  failed to create shim task: service containerd.task.v2.Task: not implemented

Then containerd can't use `Shutdown` to let the shim close. The shim
will be leaky. And also fail return if there is no ttrpc service.

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2022-07-22 23:25:40 +08:00
Wei Fu
822cc51d84 runtime/v2: manager supports server interceptor
Currently, the runc shimv2 commandline manager doesn't support ttrpc
server's customized option, for example, the ttrpc server interceptor.
This commit is to allow the task plugin can return the
`UnaryServerInterceptor` option to the manager so that the task plugin
can do enhancement before handling the incoming request, like API-level
failpoint control.

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2022-07-22 23:25:40 +08:00
wllenyj
f710505f4a shim: fix debug flag not working
As we know, shim starts twice. The first time we execute the shim with the
`start` arguments, the `-debug` argument is passed to the shim
process correctly. But the second time we execute shim, the debug flag
is ignored.

Signed-off-by: wllenyj <wllenyj@linux.alibaba.com>
2022-05-11 22:09:12 +08:00
Derek McGowan
6fda809e1b
Merge pull request #6866 from ambarve/cleanup_leaked_shim
Cleanup leaked shim process
2022-05-02 16:52:31 -07:00
Kazuyoshi Kato
29b9379560 make protos
Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
2022-04-27 21:31:16 +00:00
Kazuyoshi Kato
fcba486366 Remove gogo from .proto files
While gogo isn't actually used, it is still referenced from .proto files
and its corresponding Go package is imported from the auto-generated
files.

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
2022-04-27 20:27:55 +00:00
Amit Barve
46773c3417 Cleanup leaked shim process
If containerd crashes while creating a container the shim process stays alive and is never
cleaned up. Details are discussed in issue containerd/containerd#6860. This fixes the code
to cleanup such shim processes on containerd restart.

Signed-off-by: Amit Barve <ambarve@microsoft.com>
2022-04-27 11:43:23 -07:00
Kazuyoshi Kato
9dbe000a38 make protos
Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
2022-04-22 15:31:53 +00:00
Kazuyoshi Kato
e3db7de8f5 Remove gogo/protobuf and adjust types
This commit migrates containerd/protobuf from github.com/gogo/protobuf
to google.golang.org/protobuf and adjust types. Proto-generated structs
cannot be passed as values.

Fixes #6564.

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
2022-04-22 15:31:53 +00:00
Kazuyoshi Kato
aa1526defc Use proto.Marshal instead of calling Marshal() on objects
With google.golang.org/protobuf, proto-generated objects only have
ProtoReflect(). They don't have Marshal() anymore (see #6564).

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
2022-04-20 17:14:24 +00:00
Maksym Pavlenko
e2fd25f3d8 Move runtime v2 proto
Move runtime v2 protos to api/runtime package.

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-04-19 17:59:33 -07:00
Kazuyoshi Kato
88c0c7201e Consolidate gogo/protobuf dependencies under our own protobuf package
This would make gogo/protobuf migration easier.

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
2022-04-19 15:53:36 +00:00
Kazuyoshi Kato
80b825ca2c Remove gogoproto.stdtime
This commit removes gogoproto.stdtime, since it is not supported by
Google's official toolchain
(see https://github.com/containerd/containerd/issues/6564).

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
2022-04-19 13:39:30 +00:00
Maksym Pavlenko
b7a36950f6 [Sandbox] Add Wait and PID
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-04-08 13:33:48 -07:00
Maksym Pavlenko
0d165e6544 Restore sandboxes on daemon restart
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-04-08 13:33:48 -07:00
Maksym Pavlenko
fa02477ca9 [sandbox] Add sandbox shim skeleton
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-04-08 13:33:48 -07:00
Maksym Pavlenko
35195737e7 [sandbox] Register shim plugin after #6301
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-04-08 13:33:48 -07:00
Maksym Pavlenko
17a2aaded3 [sandbox] Add ctr support
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-04-08 13:33:48 -07:00
Maksym Pavlenko
982de8a5d5 Launch sandboxed containers from task service
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-04-08 13:33:47 -07:00
Maksym Pavlenko
6343fe3ea2 [sandbox] Implement sandbox controller
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-04-08 13:33:47 -07:00
Maksym Pavlenko
4445d0a8da [sandbox] Add protobuf definitions
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-04-08 13:33:47 -07:00
Maksym Pavlenko
2d59a39445 Use t.Setenv instead of os.Setenv
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-04-01 13:53:17 -07:00
Phil Estes
3633cae64b
Merge pull request #6706 from kzys/typeurl-upgrade
Use typeurl.Any instead of github.com/gogo/protobuf/types.Any
2022-03-25 10:38:46 -04:00
Akihiro Suda
eaf7929320
Merge pull request #5738 from thaJeztah/simplify_cgroup_add
Use cgroups.AddProc() for cgroups v1
2022-03-25 10:24:43 +09:00
Kazuyoshi Kato
96b16b447d Use typeurl.Any instead of github.com/gogo/protobuf/types.Any
This commit upgrades github.com/containerd/typeurl to use typeurl.Any.
The interface hides gogo/protobuf/types.Any from containerd's Go client.

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
2022-03-24 20:50:07 +00:00
Sebastiaan van Stijn
c091d48cb9
Use cgroups.AddProc() for cgroups v1
All occurrences only passed a PID, so we can use this utility to make
the code more symmetrical with their cgroups v2 counterparts.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-03-23 15:25:09 +01:00
Sebastiaan van Stijn
d2013d2c99
runtime: deprecate runc --criu / -criu-path option
runc option --criu is now ignored (with a warning), and the option will be
removed entirely in a future release. Users who need a non- standard criu
binary should rely on the standard way of looking up binaries in $PATH.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-03-23 14:42:43 +01:00
Kazuyoshi Kato
067611fdea Remove enumvalue_customname, goproto_enum_prefix and enum_customname
This commit removes gogoproto.enumvalue_customname,
gogoproto.goproto_enum_prefix and gogoproto.enum_customname.

All of them make proto-generated Go code more idiomatic, but we already
don't use these enums in our external-surfacing types and they are anyway
not supported by Google's official toolchain (see #6564).

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
2022-03-21 19:48:16 +00:00
Eng Zer Jun
18ec2761c0
test: use T.TempDir to create temporary test directory
The directory created by `T.TempDir` is automatically removed when the
test and all its subtests complete.

Reference: https://pkg.go.dev/testing#T.TempDir
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-03-15 14:03:50 +08:00
Kazuyoshi Kato
50ca5727b2
Merge pull request #6519 from ginglis13/ctr-runtime-path
ctr: improve error relative shim path error msg
2022-03-14 09:49:27 -07:00
Phil Estes
b521429b67
Merge pull request #6495 from thaJeztah/improve_versions
strip path-info from `-v` (version) output, and implement -v flag for containerd-shim
2022-03-08 13:57:34 -05:00
Gavin Inglis
7b045ea5f0 ctr: improve error relative shim path error msg
addresses https://github.com/containerd/containerd/issues/6464

Return an error if a runtime provided is relative.

Add context to the usage for `ctr run --runtime` indicating that
absolute path to runtime binary must be provided.

Signed-off-by: Gavin Inglis <giinglis@amazon.com>
2022-03-03 23:28:03 +00:00
Kazuyoshi Kato
296f75bd07 Do not use weak import
According to https://github.com/protocolbuffers/protobuf/issues/9184

> Weak fields are an old and deprecated internal-only feature that we never
> open sourced.

This blocks us to upgrade protoc.

Fixes #6232.

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
2022-02-21 18:26:40 +00:00
Wei Fu
7901f4b331 containerd-shim-runc-v1: return init pid when clean dead shim
If containerd-shim-runc-v1 process dead abnormally, such as received
kill -s 9 signal, panic or other unkown reasons, the containerd-shim-runc-v1
server can not reap runc container and forward init process exit event.
This will lead the container leaked in dockerd. When shim dead, containerd
will clean dead shim, here read init process pid and forward exit event
with pid at the same time.

Related to: #6402

Signed-off-by: Jeff Zvier <zvier20@gmail.com>
Signed-off-by: Wei Fu <fuweid89@gmail.com>
2022-02-20 15:12:50 +08:00
Fu Wei
3122239ee5
Merge pull request #6452 from zvier/main 2022-02-17 10:50:48 +08:00
Maksym Pavlenko
b0623a06ee Change file name for shim binary path
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-02-09 12:06:55 -08:00
Sebastiaan van Stijn
b8cadf7539
runtime/v2/shim: strip path information from version output
I noticed that path information showed up in the version output:

    ./bin/containerd-shim-runc-v1 -v
    ./bin/containerd-shim-runc-v1:
    Version:  v1.6.0-rc.1
    Revision: ad771115b82a70cfd8018d72ae489c707e63de16.m
    Go version: go1.17.2

POSIX guidelines describes; https://www.gnu.org/prep/standards/html_node/_002d_002dversion.html#g_t_002d_002dversion

> The program’s name should be a constant string; don’t compute it from argv[0].
> The idea is to state the standard or canonical name for the program, not its
> file name.

Unfortunately, this code is used by multiple binaries, so we can't fully remove
the use of os.Args[0], but let's make a start and just remove the path info.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-01-31 21:01:01 +01:00