Commit Graph

47 Commits

Author SHA1 Message Date
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
6343fe3ea2 [sandbox] Implement sandbox controller
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-04-08 13:33:47 -07: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
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
haoyun
bbe46b8c43 feat: replace github.com/pkg/errors to errors
Signed-off-by: haoyun <yun.hao@daocloud.io>
Co-authored-by: zounengren <zouyee1989@gmail.com>
2022-01-07 10:27:03 +08:00
haoyun
c0d07094be feat: Errorf usage
Signed-off-by: haoyun <yun.hao@daocloud.io>
2021-12-13 14:31:53 +08:00
Maksym Pavlenko
8b788d9dfe Expose shim process interface
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2021-11-01 07:37:01 -07:00
Maksym Pavlenko
fb5f6ce3c9 Rework task create and cleanup flow
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2021-11-01 07:37:00 -07:00
Maksym Pavlenko
2d5d3541e6 Rename task manager to shim manager
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2021-11-01 07:36:34 -07:00
Eng Zer Jun
50da673592
refactor: move from io/ioutil to io and os package
The io/ioutil package has been deprecated as of Go 1.16, see
https://golang.org/doc/go1.16#ioutil. This commit replaces the existing
io/ioutil functions with their new definitions in io and os packages.

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2021-09-21 09:50:38 +08:00
Maksym Pavlenko
d30d897ef9 Cleanup v2 shim
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2021-08-04 10:38:05 -07:00
yylt
0d45ac14e9 interface about shim build check
Signed-off-by: Yang Yang <yang8518296@163.com>
2021-07-22 09:03:12 +08:00
Wei Fu
9fdc96c095 runtime/v2: add comment for checkCopyShimLogError
After #4906, containerd opens fifo in read/write mode in linux platform
The original comment doesn't correct and is removed by #5174.

```
// original comment

// When using a multi-container shim, the fifo of the 2nd to Nth
// container will not be opened when the ctx is done. This will
// cause an ErrReadClosed that can be ignored.
```

However, we should add comment for checkCopyShimLogError to mention why
we call checkCopyShimLogError. The checkCopyShimLogError, it is to prevent
the flood of expected error messages after task die and the expected
errors depend on platform.

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2021-03-18 13:02:28 +08:00
Wei Fu
eabd9b98b6 runtime: ignore file-already-closed error if dead shim
fix: #5130

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2021-03-15 12:18:26 +08:00
payall4u
957fa3379d change flag from RDONLY to RDWR and close the fifo correct
Signed-off-by: Zhiyu Li <payall4u@qq.com>
2021-01-31 19:00:42 +08:00
Wei Fu
faec5d4ffd runtime: should not send duplicate task exit event
If the shim has been killed and ttrpc connection has been
closed, the shimErr will not be nil. For this case, the event
subscriber, like moby/moby, might have received the exit or delete
events. Just in case, we should allow ttrpc-callback-on-close to
send the exit and delete events again. And the exit status will
depend on result of shimV2.Delete.

If not, the shim has been delivered the exit and delete events.
So we should remove the task record and prevent duplicate events from
ttrpc-callback-on-close.

Fix: #4769

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2020-12-01 21:54:04 +08:00
Maksym Pavlenko
0d4734655f
Merge pull request #4647 from katiewasnothere/task_update_annotations_upstream
Add annotations to task update request api
2020-11-18 14:44:19 -08:00
Kathryn Baldauf
95ba6e9f75 Add annotations to task update request api
Signed-off-by: Kathryn Baldauf <kabaldau@microsoft.com>
2020-11-09 14:13:33 -08:00
Giuseppe Capizzi
8eda32e107 Check if a process exists before returning it
Fixes #4632.

Signed-off-by: Giuseppe Capizzi <gcapizzi@pivotal.io>
Co-authored-by: Danail Branekov <danailster@gmail.com>
2020-10-22 16:50:14 +03:00
Wei Fu
4b05d03903 runtime/v2: cleanup dead shim before delete bundle
The shim delete action needs bundle information to cleanup resources
created by shim. If the cleanup dead shim is called after delete bundle,
the part of resources maybe leaky.

The ttrpc client UserOnCloseWait() can make sure that resources are
cleanup before delete bundle, which synchronizes task deletion and
cleanup deadshim. It might slow down the task deletion, but it can make
sure that resources can be cleanup and avoid EBUSY umount case. For
example, the sandbox container like Kata/Firecracker might have mount
points over the rootfs. If containerd handles task deletion and cleanup
deadshim parallelly, the task deletion will meet EBUSY during umount and
fail to cleanup bundle, which makes case worse.

And also update cleanupAfterDeadshim, which makes sure that
cleanupAfterDeadshim must be called after shim disconnected. In some
case, shim fails to call runc-create for some reason, but the runc-create
already makes runc-init into ready state. If containerd doesn't call shim
deletion, the runc-init process will be leaky and hold the cgroup, which
makes pod terminating :(.

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2020-09-20 11:24:31 +08:00
Sebastiaan van Stijn
dc92ad6520
Replace errors.Cause() with errors.Is()
Dependencies may be switching to use the new `%w` formatting
option to wrap errors; switching to use `errors.Is()` makes
sure that we are still able to unwrap the error and detect the
underlying cause.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-05-08 14:36:45 +02:00
Wei Fu
0116352e1b runtime: ignore ttrpc.ErrClosed when delete task
For some reason, shimv2 process doesn't exist. The ttrpc doesn't detect
the connection closed by server until delete task. For this case, we
should ignore the ttrpc.ErrClosed and let task manager handle the
cleanup.

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2020-04-20 23:34:49 +08:00
Li Yuxuan
d82fa43193 v2: Call shim.Delete at first when create is failed
If the context is cancelled during `shim.Create()`, such as the client
disconnects unexpectedly. The created shim will never be deleted.
What's more, if the context is cancelled during `openShimLog()`, the
fifo will be closed and block the shim output.

Signed-off-by: Li Yuxuan <liyuxuan04@baidu.com>
2019-12-28 00:02:11 +08:00
Lantao Liu
ffcb1cc9be Fix delete error code on the containerd daemon side.
Signed-off-by: Lantao Liu <lantaol@google.com>
2019-10-09 00:28:51 -07:00
Kathryn Baldauf
b4211d94e2 fail on file not found for shim reconnect on containerd restart
Signed-off-by: Kathryn Baldauf <kabaldau@microsoft.com>
2019-09-17 14:49:29 -07:00
Michael Crosby
2e8ea9fd6b Allow timeouts to be configured in config
This adds a singleton `timeout` package that will allow services and user
to configure timeouts in the daemon.  When a service wants to use a
timeout, it should declare a const and register it's default value
inside an `init()` function for that package.  When the default config
is generated, we can use the `timeout` package to provide the available
timeout keys so that a user knows that they can configure.

These show up in the config as follows:

```toml
[timeouts]
  "io.containerd.timeout.shim.cleanup" = 5
  "io.containerd.timeout.shim.load" = 5
  "io.containerd.timeout.shim.shutdown" = 3
  "io.containerd.timeout.task.state" = 2

```

Timeouts in the config are specified in seconds.

Timeouts are very hard to get right and giving this power to the user to
configure things is a huge improvement.  Machines can be faster and
slower and depending on the CPU or load of the machine, a timeout may
need to be adjusted.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2019-08-13 17:36:32 +00:00
Li Yuxuan
08483d18ad v2: Close ttrpc connection when Delete()
This avoids potential socket leak when the connected v2 shim of runtime
serving multiple containers.

Signed-off-by: Li Yuxuan <liyuxuan04@baidu.com>
2019-08-06 20:35:59 +08:00
Michael Crosby
eb4b3e8772 Fast path getting pid from task
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2019-07-26 17:48:00 +00:00
Maksym Pavlenko
ef7f46eb7b Fix linter errors
Signed-off-by: Maksym Pavlenko <makpav@amazon.com>
2019-07-14 20:49:40 -07:00
Ace-Tang
95f9bbf18b Add timeout in load shim v2
add timeout in connect shim v2 avoid starting containerd hang

Signed-off-by: Ace-Tang <aceapril@126.com>
2019-06-19 13:10:18 +08:00
Derek McGowan
bc944553a8
Merge pull request #3206 from Random-Liu/cleanup-after-deadshim-v2
Cleanup dead v2 shim.
2019-05-10 11:56:57 -07:00
Lantao Liu
660554d671 Fix error handling for task deletion.
Signed-off-by: Lantao Liu <lantaol@google.com>
2019-05-07 08:48:54 -07:00
Phil Estes
836cf53e40
Merge pull request #3244 from Random-Liu/fix-container-cleanup
Return NotFound error for kill and delete in deleted state.
2019-05-07 16:49:45 +02:00
Lantao Liu
5c9811ded0 Cleanup dead v2 shim.
Signed-off-by: Lantao Liu <lantaol@google.com>
2019-04-30 13:45:01 -07:00
Justin Terry (VM)
969035bcbd Stop logging error on v2 multi shim log failure
Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2019-04-30 11:20:58 -07:00
Sebastiaan van Stijn
8c5779c32b
bump containerd/ttrpc 699c4e40d1e7416e08bf7019c7ce2e9beced4636
full diff: f02858b145...699c4e40d1

- containerd/ttrpc#33 Fix returns error message
- containerd/ttrpc#35 Make onclose an option

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-04-27 15:30:18 -07:00
Lantao Liu
dff7456804 Return NotFound error for kill and delete in deleted state.
Signed-off-by: Lantao Liu <lantaol@google.com>
2019-04-26 15:17:18 -07:00
Michael Crosby
84a24711e8 Add runc.v2 multi-shim
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2019-02-21 11:09:46 -05:00
Justin Terry (VM)
6468619d73 Implement the Runtime v2 Shim async task model for runhcs
Changes the requirement of a Runtime v2 shim in order to avoid race conditions
between shim and shim client sending async events. Places a requirement of what
events and what order a shim must comply to.

Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2019-01-17 14:56:37 -08:00
Justin Terry (VM)
dee0945e18 Fix spurious ttrpc client shutdown error log on success
Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2019-01-03 13:44:29 -08:00
Xiaodong Zhang
e6d787172c Fix some typo in runtime and snapshots
Signed-off-by: Xiaodong Zhang <a4012017@sina.com>
2018-09-08 08:31:42 +08:00
Michael Crosby
6ba4ddfdda Add shim log pipe for log forwarding to the daemon
A fifo on unix or named pipe on Windows will be provided to the shim.
It can be located inside the `cwd` of the shim named "log".
The shims can use the existing `github.com/containerd/containerd/log` package to log debug messages.
Messages will automatically be output in the containerd's daemon logs with the correct fiels and runtime set.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-08-07 15:31:00 -04:00
Michael Crosby
7e49c601a8 Add shim start for shim creation
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-07-17 10:21:29 -04:00
Michael Crosby
da1b5470cd Runtime v2
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-07-17 10:21:29 -04:00