Commit Graph

30 Commits

Author SHA1 Message Date
Michael Crosby
96b041e1f9 Close io when Start fails
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-07-12 10:37:39 -07:00
Michael Crosby
f93bfb6233 Add Exec IDs
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-07-06 15:23:08 -07:00
Akihiro Suda
eeb74d4e23 *_test.go: fix test conditions
- add `testutil.RequiresRoot()` to TestMain
- moved `if testing.Short{ t.Skip() }` from each of the tests into a
common `newClient()`

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2017-06-30 04:00:59 +00:00
Akihiro Suda
3d981335e3 container_test.go: fix compilation failure
# github.com/containerd/containerd
  ./container_test.go:769: cannot use &limit (type *uint64) as type *int64 in field value
  ./container_test.go:812: cannot use &limit (type *uint64) as type *int64 in field value

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2017-06-28 04:43:01 +00:00
Derek McGowan
a5fa3bb923 Merge pull request #1100 from crosbymichael/update-task
Implement task update
2017-06-27 14:39:45 -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
Michael Crosby
f36e0193a4 Implement task update
This allows tasks to have their resources updated as they are running.

Fixes #1067

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-06-26 16:38:49 -07:00
Michael Crosby
e69423f931 Merge pull request #1079 from crosbymichael/delete
Add DeleteOpts for container deletion
2017-06-23 15:25:36 -07:00
Michael Crosby
3b9d9dfa3e Fix error on doulbe Kill calls
This returns a typed error for calls to Kill when the process has
already finished.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-06-23 13:28:48 -07:00
Michael Crosby
3f45e4369e Add DeleteOpts for container deletion
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-06-23 11:57:29 -07:00
Michael Crosby
94eafaab60 Update GRPC for consistency
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-06-21 13:34:24 -07:00
Kenfe-Mickaël Laventure
ff2ceec224 Merge pull request #1019 from crosbymichael/delete-running
Don't delete container with task
2017-06-20 13:14:16 -07:00
Michael Crosby
79631498af Set image on rootfs options
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-06-16 13:51:24 -07:00
Michael Crosby
6c4a2691b3 Don't delete container with task
Make sure we don't delete a container with a live task

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-06-15 16:37:50 -07:00
Michael Crosby
9226143b16 Merge pull request #978 from crosbymichael/process-delete
Add DeleteProcess API for removing execs
2017-06-12 10:00:12 -07:00
Michael Crosby
ff598449d1 Add DeleteProcess API for removing execs
We need a separate API for handing the exit status and deletion of
Exec'd processes to make sure they are properly cleaned up within the
shim and daemon.

Fixes #973

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-06-12 09:32:23 -07:00
Michael Crosby
be5da790a3 Use t.Name() for container ids in tests
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-06-12 09:27:17 -07:00
Michael Crosby
4c1af8fdd8 Port ctr to use client
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-06-06 14:53:50 -07:00
Stephen J Day
af2718b01f
namespaces: support within containerd
To support multi-tenancy, containerd allows the collection of metadata
and runtime objects within a heirarchical storage primitive known as
namespaces. Data cannot be shared across these namespaces, unless
allowed by the service. This allows multiple sets of containers to
managed without interaction between the clients that management. This
means that different users, such as SwarmKit, K8s, Docker and others can
use containerd without coordination. Through labels, one may use
namespaces as a tool for cleanly organizing the use of containerd
containers, including the metadata storage for higher level features,
such as ACLs.

Namespaces

Namespaces cross-cut all containerd operations and are communicated via
context, either within the Go context or via GRPC headers. As a general
rule, no features are tied to namespace, other than organization. This
will be maintained into the future. They are created as a side-effect of
operating on them or may be created manually. Namespaces can be labeled
for organization. They cannot be deleted unless the namespace is empty,
although we may want to make it so one can clean up the entirety of
containerd by deleting a namespace.

Most users will interface with namespaces by setting in the
context or via the `CONTAINERD_NAMESPACE` environment variable, but the
experience is mostly left to the client. For `ctr` and `dist`, we have
defined a "default" namespace that will be created up on use, but there
is nothing special about it. As part of this PR we have plumbed this
behavior through all commands, cleaning up context management along the
way.

Namespaces in Action

Namespaces can be managed with the `ctr namespaces` subcommand. They
can be created, labeled and destroyed.

A few commands can demonstrate the power of namespaces for use with
images. First, lets create a namespace:

```
$ ctr namespaces create foo mylabel=bar
$ ctr namespaces ls
NAME LABELS
foo  mylabel=bar
```

We can see that we have a namespace `foo` and it has a label. Let's pull
an image:

```
$ dist pull docker.io/library/redis:latest
docker.io/library/redis:latest: resolved       |++++++++++++++++++++++++++++++++++++++|
manifest-sha256:548a75066f3f280eb017a6ccda34c561ccf4f25459ef8e36d6ea582b6af1decf: done           |++++++++++++++++++++++++++++++++++++++|
layer-sha256:d45bc46b48e45e8c72c41aedd2a173bcc7f1ea4084a8fcfc5251b1da2a09c0b6: done           |++++++++++++++++++++++++++++++++++++++|
layer-sha256:5b690bc4eaa6434456ceaccf9b3e42229bd2691869ba439e515b28fe1a66c009: done           |++++++++++++++++++++++++++++++++++++++|
config-sha256:a858478874d144f6bfc03ae2d4598e2942fc9994159f2872e39fae88d45bd847: done           |++++++++++++++++++++++++++++++++++++++|
layer-sha256:4cdd94354d2a873333a205a02dbb853dd763c73600e0cf64f60b4bd7ab694875: done           |++++++++++++++++++++++++++++++++++++++|
layer-sha256:10a267c67f423630f3afe5e04bbbc93d578861ddcc54283526222f3ad5e895b9: done           |++++++++++++++++++++++++++++++++++++++|
layer-sha256:c54584150374aa94b9f7c3fbd743adcff5adead7a3cf7207b0e51551ac4a5517: done           |++++++++++++++++++++++++++++++++++++++|
layer-sha256:d1f9221193a65eaf1b0afc4f1d4fbb7f0f209369d2696e1c07671668e150ed2b: done           |++++++++++++++++++++++++++++++++++++++|
layer-sha256:71c1f30d820f0457df186531dc4478967d075ba449bd3168a3e82137a47daf03: done           |++++++++++++++++++++++++++++++++++++++|
elapsed: 0.9 s total:   0.0 B (0.0 B/s)
INFO[0000] unpacking rootfs
INFO[0000] Unpacked chain id: sha256:41719840acf0f89e761f4a97c6074b6e2c6c25e3830fcb39301496b5d36f9b51
```

Now, let's list the image:

```
$ dist images ls
REF                            TYPE  DIGEST SIZE
docker.io/library/redis:latest application/vnd.docker.distribution.manifest.v2+json sha256:548a75066f3f280eb017a6ccda34c561ccf4f25459ef8e36d6ea582b6af1decf 72.7 MiB
```

That looks normal. Let's list the images for the `foo` namespace and see
this in action:

```
$ CONTAINERD_NAMESPACE=foo dist images ls
REF TYPE DIGEST SIZE
```

Look at that! Nothing was pulled in the namespace `foo`. Let's do the
same pull:

```
$ CONTAINERD_NAMESPACE=foo dist pull docker.io/library/redis:latest
docker.io/library/redis:latest: resolved       |++++++++++++++++++++++++++++++++++++++|
manifest-sha256:548a75066f3f280eb017a6ccda34c561ccf4f25459ef8e36d6ea582b6af1decf: done           |++++++++++++++++++++++++++++++++++++++|
layer-sha256:d45bc46b48e45e8c72c41aedd2a173bcc7f1ea4084a8fcfc5251b1da2a09c0b6: done           |++++++++++++++++++++++++++++++++++++++|
config-sha256:a858478874d144f6bfc03ae2d4598e2942fc9994159f2872e39fae88d45bd847: done           |++++++++++++++++++++++++++++++++++++++|
layer-sha256:4cdd94354d2a873333a205a02dbb853dd763c73600e0cf64f60b4bd7ab694875: done           |++++++++++++++++++++++++++++++++++++++|
layer-sha256:c54584150374aa94b9f7c3fbd743adcff5adead7a3cf7207b0e51551ac4a5517: done           |++++++++++++++++++++++++++++++++++++++|
layer-sha256:71c1f30d820f0457df186531dc4478967d075ba449bd3168a3e82137a47daf03: done           |++++++++++++++++++++++++++++++++++++++|
layer-sha256:d1f9221193a65eaf1b0afc4f1d4fbb7f0f209369d2696e1c07671668e150ed2b: done           |++++++++++++++++++++++++++++++++++++++|
layer-sha256:10a267c67f423630f3afe5e04bbbc93d578861ddcc54283526222f3ad5e895b9: done           |++++++++++++++++++++++++++++++++++++++|
layer-sha256:5b690bc4eaa6434456ceaccf9b3e42229bd2691869ba439e515b28fe1a66c009: done           |++++++++++++++++++++++++++++++++++++++|
elapsed: 0.8 s total:   0.0 B (0.0 B/s)
INFO[0000] unpacking rootfs
INFO[0000] Unpacked chain id: sha256:41719840acf0f89e761f4a97c6074b6e2c6c25e3830fcb39301496b5d36f9b51
```

Wow, that was very snappy! Looks like we pulled that image into out
namespace but didn't have to download any new data because we are
sharing storage. Let's take a peak at the images we have in `foo`:

```
$ CONTAINERD_NAMESPACE=foo dist images ls
REF                            TYPE DIGEST SIZE
docker.io/library/redis:latest application/vnd.docker.distribution.manifest.v2+json sha256:548a75066f3f280eb017a6ccda34c561ccf4f25459ef8e36d6ea582b6af1decf 72.7 MiB
```

Now, let's remove that image from `foo`:

```
$ CONTAINERD_NAMESPACE=foo dist images rm
docker.io/library/redis:latest
```

Looks like it is gone:

```
$ CONTAINERD_NAMESPACE=foo dist images ls
REF TYPE DIGEST SIZE
```

But, as we can see, it is present in the `default` namespace:

```
$ dist images ls
REF                            TYPE DIGEST SIZE
docker.io/library/redis:latest application/vnd.docker.distribution.manifest.v2+json sha256:548a75066f3f280eb017a6ccda34c561ccf4f25459ef8e36d6ea582b6af1decf 72.7 MiB
```

What happened here? We can tell by listing the namespaces to get a
better understanding:

```
$ ctr namespaces ls
NAME    LABELS
default
foo     mylabel=bar
```

From the above, we can see that the `default` namespace was created with
the standard commands without the environment variable set. Isolating
the set of shared images while sharing the data that matters.

Since we removed the images for namespace `foo`, we can remove it now:

```
$ ctr namespaces rm foo
foo
```

However, when we try to remove the `default` namespace, we get an error:

```
$ ctr namespaces rm default
ctr: unable to delete default: rpc error: code = FailedPrecondition desc = namespace default must be empty
```

This is because we require that namespaces be empty when removed.

Caveats

- While most metadata objects are namespaced, containers and tasks may
exhibit some issues. We still need to move runtimes to namespaces and
the container metadata storage may not be fully worked out.
- Still need to migrate content store to metadata storage and namespace
the content store such that some data storage (ie images).
- Specifics of snapshot driver's relation to namespace needs to be
worked out in detail.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-06-06 13:50:33 -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
Michael Crosby
00734ab04a Return fifo paths from Shim
This allows attach of existing fifos to be done without any information
stored on the client side.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-06-01 14:12:02 -07:00
Michael Crosby
43fb19e01c Add Load for container and Task with Attach
This adds both container and task loading of running tasks as well as
reattaching to the IO of the task after load.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-06-01 14:12:02 -07:00
Michael Crosby
9890bed1e1 Add CloseStdin to task
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-06-01 14:10:04 -07:00
Michael Crosby
ff54c88e99 Add Processes() to client
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-05-31 13:34:38 -07:00
Michael Crosby
ebf935d990 Add exec support to client
This also fixes a deadlock in the shim's reaper where execs would lockup
and/or miss a quick exiting exec process's exit status.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-05-31 11:50:23 -07:00
Michael Crosby
b3f891b09f Add integration tests for running containers
Add travis support for running integration tests with the client package
and go test framework

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-05-26 15:50:01 -07:00
Michael Crosby
cebe099358 Add test flag for setting containerd address
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-05-25 15:41:10 -07:00
Michael Crosby
d0b22290ec Don't require rootfs if not set on container
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-05-25 11:17:36 -07:00
Michael Crosby
8cd882c570 Add test -short for non-integration tests
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-05-24 16:13:54 -07:00
Michael Crosby
d0e5732f0b Add initial containerd *Client
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-05-24 14:08:58 -07:00