Commit Graph

78 Commits

Author SHA1 Message Date
Kenfe-Mickael Laventure
c23f29ebce
containerd-shim: Don't try to delete container twice
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2017-08-29 08:27:44 -07:00
Kenfe-Mickael Laventure
e661be6a9c
Fix failure to connect to shim on daemon restart
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2017-08-11 09:34:29 -07:00
Michael Crosby
d513dd2bfd Fix race with task checkpoint
Because runc will delete a container after a successful checkpoint we
need to handle a NotFound error from runc on delete.

There is also a race between SIGKILL'ing the shim and it actually
exiting to unmount the tasks rootfs, we need to loop and wait for the
task to actually be reaped before trying to delete the rootfs+bundle.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-08-10 16:35:03 -04:00
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
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
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
7b6ff6ec89 event forwarding without shim
Fixes #1138

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-07-31 10:05:24 -04: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
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
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
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
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
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
a60511d5aa Use typeurl package for spec types
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-07-05 15:37:26 -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
Michael Crosby
040558cf81 Remove runtime.Event types
This uses the events service types for runtime events

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-06-28 10:47:22 -07:00
Michael Crosby
7c8acca29a Move runtime interfaces to runtime package
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-06-28 10:10:59 -07:00
Michael Crosby
6ec84ef83c Add namespace to container metrics
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-06-27 11:54:14 -07:00
Phil Estes
79e6a93624
Fix incorrect reference to the gRPC runtime name as a binary
Until we have a way to preserve the initial command used to start the
container, we have to default to the default `runc` found on the $PATH.
This code after the last refactor of shim/API is incorrectly using the
gRPC object reference of the v1 runtime as a binary name which causes
os.Exec() errors.

Signed-off-by: Phil Estes <estesp@gmail.com>
Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com>
2017-06-26 19:49:09 -04:00
Kenfe-Mickael Laventure
6574055dec
linux: Pass correct type when emitting RuntimeDelete event
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2017-06-23 17:55:23 -07:00
Michael Crosby
990536f2cc Move shim protos into linux pkg
This moves the shim's API and protos out of the containerd services
package and into the linux runtime package. This is because the shim is
an implementation detail of the linux runtime that we have and it is not
a containerd user facing api.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-06-23 16:21:47 -07:00
Stephen J Day
12c0daa9c9
api/types: consolidate types package
To simplify use of types, we have consolidate the packages for the mount
and descriptor protobuf types into a single Go package. We also drop the
versioning from the type packages, as these types will remain the same
between versions.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-06-23 13:50:28 -07:00
Stephen J Day
c05be46348
events: move types into service package
When using events, it was found to be fairly unwieldy with a number of
extra packages. For the most part, when interacting with the events
service, we want types of the same version of the service. This has been
accomplished by moving all events types into the events package.

In addition, several fixes to the way events are marshaled have been
included. Specifically, we defer to the protobuf type registration
system to assemble events and type urls, with a little bit sheen on top
of add a containerd.io oriented namespace.

This has resulted in much cleaner event consumption and has removed the
reliance on error prone type urls, in favor of concrete types.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-06-22 19:12:25 -07:00
Stephen J Day
12a6beaeeb
*: update import paths to use versioned services
Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-06-21 18:29:06 -07:00
Michael Crosby
8b2cf6e8e6 Fix Wait() on process/tasks
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-06-21 13:48:24 -07:00
Michael Crosby
8830866eed Remove events from Runtime
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-06-21 13:34:24 -07:00
Evan Hazlett
935645b03a events: add protos
Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>

events: update events package to include emitter and use envelope proto

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>

events: add events service

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>

events: enable events service and update ctr events to use events service

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>

event listeners

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>

events: helper func for emitting in services

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>

events: improved cli for containers and tasks

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>

create event envelope with poster

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>

events: introspect event data to use for type url

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>

events: use pb encoding; add event types

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>

events: instrument content and snapshot services with events

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>

events: instrument image service with events

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>

events: instrument namespace service with events

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>

events: add namespace support

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>

events: only send events from namespace requested from client

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>

events: switch to go-events for broadcasting

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
2017-06-20 10:47:28 -04:00
Michael Crosby
94e7f8e943 Setup plugin ids and dependencies
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-06-14 16:17:20 -07:00
Kenfe-Mickael Laventure
709ba260de
linux: Ensure shim is killed if we can't connect to it initially
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2017-06-14 10:21:48 -07:00
Kenfe-Mickael Laventure
171759a233
linux: Return grpc error description only
This avoid having "rpc error: code = Unknown" in the final output.

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2017-06-14 10:21:48 -07:00
Michael Crosby
588c11852b Move task list to runtimes
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-06-09 10:37:33 -07:00
Michael Crosby
745398b2e9 Remove tasks map from service
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-06-09 10:35:17 -07:00
Michael Crosby
497db9ac06 Namespace tasks via runc --root
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-06-06 16:31:00 -07:00
Michael Crosby
a8c5542ba8 Add checkpoint and restore to client package
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-06-06 09:58:33 -07:00
Phil Estes
7071276f64 Merge pull request #943 from mlaventure/honor-runtime-conf
Use conf value when killing loaded container
2017-06-01 17:12:17 -04:00
Kenfe-Mickael Laventure
357c47b1a3 Use conf value when killing loaded container
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2017-05-31 14:51:28 -07:00
Ian Campbell
a5d246404c Reconnect to shim event stream after containerd restart
There are three aspects which need to be covered:

 - the runtime needs to restart its event pump when it reconnects (in
   loadContainer).
 - on the server side shim needs to monitor the stream context so it knows when
   the connection goes away.
 - if the shim's stream.Send() fails (because the stream died between taking
   the event off the channel and calling stream.Send()) then to avoid losing
   that event the shim should remember it and send it out first on the next
   stream.

The shim's event production machinery only handles producing a single event
stream, so add an interlock to ensure there is only one reader of the
`s.events` channel at a time. Subsequent attempts to use Events will block
until the existing owner is done.

Fixes #921.

Signed-off-by: Ian Campbell <ian.campbell@docker.com>
2017-05-31 13:48:44 +01:00
Derek McGowan
e1ed4a2ea4
Add json storage for container storage
This is just a temporary storage solution to get
containers running on the new code.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-05-23 14:22:20 -07:00
Stephen J Day
539742881d
api/services: define the container metadata service
Working from feedback on the existing implementation, we have now
introduced a central metadata object to represent the lifecycle and pin
the resources required to implement what people today know as
containers. This includes the runtime specification and the root
filesystem snapshots. We also allow arbitrary labeling of the container.
Such provisions will bring the containerd definition of container closer
to what is expected by users.

The objects that encompass today's ContainerService, centered around the
runtime, will be known as tasks. These tasks take on the existing
lifecycle behavior of containerd's containers, which means that they are
deleted when they exit. Largely, there are no other changes except for
naming.

The `Container` object will operate purely as a metadata object. No
runtime state will be held on `Container`. It only informs the execution
service on what is required for creating tasks and the resources in use
by that container. The resources referenced by that container will be
deleted when the container is deleted, if not in use. In this sense,
users can create, list, label and delete containers in a similar way as
they do with docker today, without the complexity of runtime locks that
plagues current implementations.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-05-22 23:27:53 -07:00
Michael Crosby
7cc1b64bd8 Add checkpoint and restore
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>

Update go-runc to 49b2a02ec1ed3e4ae52d30b54a291b75

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>

Add shim to restore creation

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>

Keep checkpoint path in service

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>

Add C/R to non-shim build

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>

Checkpoint rw and image

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>

Pause container on bind checkpoints

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>

Return dump.log in error on checkpoint failure

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>

Pause container for checkpoint

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>

Update runc to 639454475cb9c8b861cc599f8bcd5c8c790ae402

For checkpoint into to work you need runc version
639454475cb9c8b861cc599f8bcd5c8c790ae402 + and criu 3.0 as this is what
I have been testing with.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>

Move restore behind create calls

This remove the restore RPCs in favor of providing the checkpoint
information to the `Create` calls of a container.  If provided, the
container will be created/restored from the checkpoint instead of an
existing container.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>

Regen protos after rebase

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-05-22 15:34:45 -07:00
Kenfe-Mickael Laventure
dd16c0583b Revert "Merge pull request #853 from AkihiroSuda/check-rootfs"
This reverts commit c1530b5b76, reversing
changes made to 3695ba77bb.

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2017-05-16 14:48:13 -07:00
Kenfe-Mickael Laventure
aac425c761 Terminate linux shim on create failure
Since an error is returned via the RPC clients will assume (rightly so)
that a call to the Delete() RPC is not necessary.

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2017-05-16 13:31:06 -07:00
Derek McGowan
c1530b5b76 Merge pull request #853 from AkihiroSuda/check-rootfs
linux: error out if no rootfs specified
2017-05-16 10:38:25 -07:00
Kenfe-Mickael Laventure
f95ad5a280 Don't print the transport closing error for shim events
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2017-05-15 15:27:40 -07:00