Commit Graph

183 Commits

Author SHA1 Message Date
Phil Estes
c8cd3d9080
Fix bundle removal with the reappearance of state dir
Bundle removal now requires removing both workdir and path locations on
delete in shim.

Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com>
2017-08-07 17:50:22 -04:00
Phil Estes
e9b86af848 Merge pull request #1283 from mlaventure/resurrect-state-dir
Resurrect State directory
2017-08-07 10:41:21 -04:00
Stephen J Day
a73eb2b2ce
api: generate merged descriptors when building protobufs
When we generate protobufs, descriptors outlining all messages and
services are merged into a single file that can be used to identify
unexpected changes to the API that may affect stability. We follow a
similar process to Go's stability guarantees using the protobuf
descriptors to identify changes before they become a problem.

Please see README.md for details.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-08-04 16:50:28 -07:00
Phil Estes
ff15d18f1f Merge pull request #1287 from crosbymichael/exitstatus
Return exit status from Wait of stopped process
2017-08-04 11:49:51 -04:00
Kenfe-Mickael Laventure
8700e23a10
Use root dir when storing temporary checkpoint data
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2017-08-03 14:38:18 -07:00
Michael Crosby
9f13b414b9 Return exit status from Wait of stopped process
This changes Wait() from returning an error whenever you call wait on a
stopped process/task to returning the exit status from the process.

This also adds the exit status to the Status() call on a process/task so
that a user can Wait(), check status, then cancel the wait to avoid
races in event handling.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-08-03 17:22:33 -04:00
Kenfe-Mickael Laventure
fbe4751b83
Use a temp socket to receive the console from runc
This greatly reduce the risk that we will hit the unix socket maximum path
length.

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2017-08-03 10:44:10 -07:00
Kenfe-Mickael Laventure
642620cae3
Resurrect State directory
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2017-08-03 09:15:53 -07:00
Michael Crosby
bf4838eb71 Shutdown console after process exits
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-08-02 17:09:50 -04:00
Michael Crosby
d18af8699c Update for epoll console handling
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-08-02 13:50:08 -04:00
Michael Crosby
504033e373 Add Get of task and process state
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-08-02 13:50:08 -04:00
Michael Crosby
9f08965699 Change Exited/Status to SetExited/ExitStatus
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-08-02 13:50:08 -04:00
Michael Crosby
a2a3451925 Implement Exec + Start for tasks service
This splits up the exec creation and start in the tasks service

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-08-02 13:50:08 -04:00
Michael Crosby
63878d14ea Add create/start to exec processes in shim
This splits up the create and start of an exec process in the shim to
have two separate steps like the initial process.  This will allow
better state reporting for individual process along with a more robust
wait for execs.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-08-02 13:50:08 -04:00
Stephen J Day
7ed88c1e36
linux/shim: use events.Publisher interface
Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-07-31 14:23:51 -07:00
Stephen Day
92d737f4ae Merge pull request #1259 from dqminh/epoll-io
Use Epoll to perform I/O in linux
2017-07-31 13:47:41 -07:00
Stephen J Day
af2d7f0e55
events: initial support for filters
This change further plumbs the components required for implementing
event filters. Specifically, we now have the ability to filter on the
`topic` and `namespace`.

In the course of implementing this functionality, it was found that
there were mismatches in the events API that created extra serialization
round trips. A modification to `typeurl.MarshalAny` and a clear
separation between publishing and forwarding allow us to avoid these
serialization issues.

Unfortunately, this has required a few tweaks to the GRPC API, so this
is a breaking change. `Publish` and `Forward` have been clearly separated in
the GRPC API. `Publish` honors the contextual namespace and performs
timestamping while `Forward` simply validates and forwards. The behavior
of `Subscribe` is to propagate events for all namespaces unless
specifically filtered (and hence the relation to this particular change.

The following is an example of using filters to monitor the task events
generated while running the [bucketbench tool](https://github.com/estesp/bucketbench):

```
$ ctr events 'topic~=/tasks/.+,namespace==bb'
...
2017-07-28 22:19:51.78944874 +0000 UTC   bb        /tasks/start   {"container_id":"bb-ctr-6-8","pid":25889}
2017-07-28 22:19:51.791893688 +0000 UTC   bb        /tasks/start   {"container_id":"bb-ctr-4-8","pid":25882}
2017-07-28 22:19:51.792608389 +0000 UTC   bb        /tasks/start   {"container_id":"bb-ctr-2-9","pid":25860}
2017-07-28 22:19:51.793035217 +0000 UTC   bb        /tasks/start   {"container_id":"bb-ctr-5-6","pid":25869}
2017-07-28 22:19:51.802659622 +0000 UTC   bb        /tasks/start   {"container_id":"bb-ctr-0-7","pid":25877}
2017-07-28 22:19:51.805192898 +0000 UTC   bb        /tasks/start   {"container_id":"bb-ctr-3-6","pid":25856}
2017-07-28 22:19:51.832374931 +0000 UTC   bb        /tasks/exit   {"container_id":"bb-ctr-8-6","id":"bb-ctr-8-6","pid":25864,"exited_at":"2017-07-28T22:19:51.832013043Z"}
2017-07-28 22:19:51.84001249 +0000 UTC   bb        /tasks/exit   {"container_id":"bb-ctr-2-9","id":"bb-ctr-2-9","pid":25860,"exited_at":"2017-07-28T22:19:51.839717714Z"}
2017-07-28 22:19:51.840272635 +0000 UTC   bb        /tasks/exit   {"container_id":"bb-ctr-7-6","id":"bb-ctr-7-6","pid":25855,"exited_at":"2017-07-28T22:19:51.839796335Z"}
...
```

In addition to the events changes, we now display the namespace origin
of the event in the cli tool.

This will be followed by a PR to add individual field filtering for the
events API for each event type.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-07-31 12:53:18 -07:00
Michael Crosby
7b6ff6ec89 event forwarding without shim
Fixes #1138

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-07-31 10:05:24 -04:00
Daniel Dao
8e53465842
use epoll to manage console i/o in linux
this adds a `platform` interface for shim service to manage platform-specific
behaviors such as I/O (which uses epoll in linux to work around bugs with applications
that closes all consoles i.e. https://github.com/opencontainers/runc/pull/1434
and https://github.com/moby/moby/issues/27202)

Its expected that we only have 1 epollfd per containerd_shim to manage all processes.
Since all the work are done outside of the container runtime, upgrading of runc
is not required and should be done separately.

Signed-off-by: Daniel Dao <dqminh89@gmail.com>
2017-07-30 10:50:39 +01:00
Michael Crosby
98a86c4d38 Add ShimCgroup path for placing shim in cgroup
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-07-27 15:25:27 -04:00
Michael Crosby
a0a5cc7787 Add user namespace support to client
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-07-27 11:06:20 -04:00
Stephen J Day
a615a6fe5d
events: refactor event distribution
In the course of setting out to add filters and address some cleanup, it
was found that we had a few problems in the events subsystem that needed
addressing before moving forward.

The biggest change was to move to the more standard terminology of
publish and subscribe. We make this terminology change across the Go
interface and the GRPC API, making the behavior more familier. The
previous system was very context-oriented, which is no longer required.

With this, we've removed a large amount of dead and unneeded code. Event
transactions, context storage and the concept of `Poster` is gone. This
has been replaced in most places with a `Publisher`, which matches the
actual usage throughout the codebase, removing the need for helpers.

There are still some questions around the way events are handled in the
shim. Right now, we've preserved some of the existing bugs which may
require more extensive changes to resolve correctly.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-07-25 15:08:09 -07:00
Andrew Pennebaker
1d2a079f08
update to github.com/sirupsen/logrus v1.0.0
Signed-off-by: Andrew Pennebaker <apennebaker@datapipe.com>
2017-07-21 15:39:14 -07:00
Ian Campbell
d42cb88ba2 Loop umount'ing rootfs until there are no more mounts
This is simpler than trying to count how many successful mounts we made.

Signed-off-by: Ian Campbell <ian.campbell@docker.com>
2017-07-20 10:50:08 +01:00
Ian Campbell
d63d2ecf6c Simplify mount cleanup on failure by using defer
This avoids someone adding a new error path and forgetting to call the cleanup
function.

We prefer to use an explicit flag to gate the clean rather than relying on `err
!= nil` so we don't have to rely on people never accidentally shadowing the
`err` as seen by the closure.

Signed-off-by: Ian Campbell <ian.campbell@docker.com>
2017-07-20 10:50:08 +01:00
Ian Campbell
300f083127 Cleanup mounts if we fail to mount one element of rootfs
Signed-off-by: Ian Campbell <ian.campbell@docker.com>
2017-07-20 10:50:08 +01:00
Ian Campbell
8b365117a2 containerd-shim: Do not remount root MS_SLAVE
Mounting as MS_SLAVE here breaks use cases which want to use
rootPropagation=shared in order to expose mounts to the host (and other
containers binding the same subtree), mounting as e.g. MS_SHARED is pointless
in this context so just remove.

Having done this we also need to arrange to manually clean up the mounts on
delete, so do so.

Note that runc will also setup root as required by rootPropagation, defaulting
to MS_PRIVATE.

Fixes #1132.

Signed-off-by: Ian Campbell <ian.campbell@docker.com>
2017-07-20 10:50:08 +01:00
Derek McGowan
a8504277cc Merge pull request #1209 from stevvooe/remove-errors
linux, linux/shim: remove error definitions
2017-07-18 19:18:23 -07:00
Stephen J Day
1ecb2ea30d
linux/shim: remove redundant topic prefix
Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-07-18 18:19:25 -07:00
Stephen J Day
6d0bcd5aec
linux, linux/shim: remove error definitions
Since we now have a common set of error definitions, mapped to existing
error codes, we no longer need the specialized error codes used for
interaction with linux processes. The main issue was that string
matching was being used to map these to useful error codes. With this
change, we use errors defined in the `errdefs` package, which map
cleanly to GRPC error codes and are recoverable on either side of the
request.

The main focus of this PR was in removin these from the shim. We may
need follow ups to ensure error codes are preserved by the `Tasks`
service.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-07-18 15:56:49 -07:00
Kenfe-Mickael Laventure
e4beb7c554
Use constants for runtime event topics
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2017-07-18 14:19:48 +02:00
Kenfe-Mickael Laventure
a578730a94
Update linux events topic
This also remove the duplicate events for Task{Create,Start,Delete}

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2017-07-18 13:47:28 +02:00
Kenfe-Mickael Laventure
88c1db5ca5
Move taskList to the runtime package
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2017-07-13 13:53:22 +02:00
Michael Crosby
e110706376 Merge pull request #1170 from stevvooe/identifier-validation
namespaces, identifiers: split validation
2017-07-12 15:15:17 -07:00
Stephen J Day
9e5bd5a2dc
namespaces, identifiers: split validation
After review, there are cases where having common requirements for
namespaces and identifiers creates contention between applications.  One
example is that it is nice to have namespaces comply with domain name
requirement, but that does not allow underscores, which are required for
certain identifiers.

The namespaces validation has been reverted to be in line with RFC 1035.
Existing identifiers has been modified to allow simply alpha-numeric
identifiers, while limiting adjacent separators.

We may follow up tweaks for the identifier charset but this split should
remove the hard decisions.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-07-12 14:46:47 -07:00
Michael Crosby
3b8018d8cf Remove protos from Go client API
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-07-12 14:32:37 -07:00
Michael Crosby
2b6d790ff4 Refactor runtime events into Task* types
This removes the RuntimeEvent super proto with enums into separate
runtime event protos to be inline with the other events that are output
by containerd.

This also renames the runtime events into Task* events.

Fixes #1071

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-07-12 10:57:57 -07:00
Ian Campbell
194b6e4f06 Start of day configuration of shim debug setting
This makes it possible to enable shim debug by adding the following to
`config.toml`:

    [plugins.linux]
    shim_debug = true

I moved the debug setting from the `client.Config struct` to an argument to
`client.WithStart` since this is the only place it would be used.

Signed-off-by: Ian Campbell <ian.campbell@docker.com>
2017-07-12 17:48:27 +01:00
Michael Crosby
58da62dd0f Add runtime events for pause,resume,checkpoint
Fixes #1068

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-07-11 12:38:20 -07:00
Derek McGowan
54e2b9db57 Merge pull request #1152 from ijc/drop-unused-variable
linux: Drop unused variable `c` by discarding unused assignment
2017-07-11 09:40:15 -07:00
Ian Campbell
0a580cbb72 linux: Drop unused variable c by discarding unused assignment
The compiler doesn't spot this, but guru does.

This seems to have become unused in 79e6a93624 ("Fix incorrect reference to
the gRPC runtime name as a binary").

Signed-off-by: Ian Campbell <ian.campbell@docker.com>
2017-07-11 13:28:59 +01:00
Michael Crosby
6578565216 Use event service post for shim events
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-07-07 16:30:57 -07:00
Michael Crosby
f93bfb6233 Add Exec IDs
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-07-06 15:23:08 -07:00
Michael Crosby
4b9a8ee13e Require *T for typeurl interaction
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-07-06 13:14:48 -07:00
Michael Crosby
a60511d5aa Use typeurl package for spec types
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-07-05 15:37:26 -07:00
Samuel Ortiz
b67398af15 linux: Make containerd less runc specific
We hope that containerd supports any OCI compliant runtime, and not only
runc.
This patch fixes all the error messages to not be completely runc
specific and change the initProcess structure to have its runtime
pointer be called 'runtime' and not 'runc'

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2017-07-03 17:45:23 +02:00
Kenfe-Mickael Laventure
ccbe92dc08 Move WithExit to runcopts package
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-06-29 15:50:39 -07:00
Michael Crosby
124f430d44 Update base types url for runc opts
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-06-29 15:44:23 -07:00
Michael Crosby
72831b6985 Use Any instead of []byte
This allows us to get the fully TypeURL for consuming code.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-06-29 15:32:45 -07:00
Michael Crosby
82d0208aaa Implement options for runtime specific settings
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-06-29 15:32:45 -07:00