Commit Graph

670 Commits

Author SHA1 Message Date
Lifubang
1d9b96988f fix when --config provided, don't need Image/RootFS
Signed-off-by: Lifubang <lifubang@aliyun.com>
2018-08-27 11:18:25 +08:00
Lifubang
dc6ed04ff5 support relative rootfs path in ctr
Signed-off-by: Lifubang <lifubang@aliyun.com>
2018-08-24 07:56:37 +08:00
Phil Estes
830363acac
Merge pull request #2544 from kadisi/process_args
set args value of process if args is nil
2018-08-22 15:31:30 -04:00
Michael Crosby
4f644dbfd5 Copy io into and out of console
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-08-22 14:04:17 -04:00
kadisi
7dae56671d set args value of process if args is nil
Signed-off-by: kadisi <iamkadisi@163.com>
2018-08-21 09:44:50 +08:00
Michael Crosby
b67ea850af Add opt for default unix device permissions
These opts either inherit the parent cgroup device.list or append the
default unix devices like /dev/null /dev/random so that the container
has access.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-08-15 11:52:43 -04:00
Michael Crosby
3be457d7d6 Move content.Fetch configuration to struct
This makes it easier for callers to call this function and populate the
config without relying on specific flags across commands.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-08-09 10:26:31 -04:00
Phil Estes
2783a19b10
Merge pull request #2518 from crosbymichael/install
Add install support for binary images
2018-08-03 08:45:02 -04:00
Michael Crosby
5a47c5ec1d Add lib support as an option
Some images like `criu` will have extra libs that it requires.  This
adds lib support via LD_LIBRARY_PATH and InstallOpts

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-08-02 17:11:29 -04:00
Evan Hazlett
1537f31381 Add install support for binary images
This adds a way for users to programatically install containerd binary
dependencies.

With runtime v2 and new shim's being built, it will be a challenge to
get those onto machines.  Users would have to find the link, download,
place it in their path, yada yada yada.

With this functionality of a managed `/opt` directory, containerd can
use existing image and distribution infra. to get binarys, shims, etc
onto the system.

Configuration:

*default:* `/opt/containerd`

*containerd config:*
```toml
[plugins.opt]
	path = "/opt/mypath"

```

Usage:

*code:*

```go
image, err := client.Pull(ctx, "docker.io/crosbymichael/runc:latest")
client.Install(ctx, image)
```

*ctr:*

```bash
ctr content fetch docker.io/crosbymichael/runc:latest
ctr install docker.io/crosbymichael/runc:latest
```

You can manage versions and see what is running via standard image
commands.

Images:

These images MUST be small and only contain binaries.

```Dockerfile
FROM scratch
Add runc /bin/runc
```

Containerd will only extract files in `/bin` of the image.

Later on, we can add support for `/lib`.

The code adds a service to manage an `/opt/containerd` directory and
provide that path to callers via the introspection service.

How to Test:

Delete runc from your system.

```bash
> sudo ctr run --rm  docker.io/library/redis:alpine redis
ctr: OCI runtime create failed: unable to retrieve OCI runtime error (open /run/containerd/io.containerd.runtime.v1.linux/default/redis/log.json: no such file or directory): exec: "runc": executable file not found in $PATH: unknown

> sudo ctr content fetch docker.io/crosbymichael/runc:latest
> sudo ctr  install docker.io/crosbymichael/runc:latest

> sudo ctr run --rm  docker.io/library/redis:alpine redis
1:C 01 Aug 15:59:52.864 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
1:C 01 Aug 15:59:52.864 # Redis version=4.0.10, bits=64, commit=00000000, modified=0, pid=1, just started
1:C 01 Aug 15:59:52.864 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
1:M 01 Aug 15:59:52.866 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
1:M 01 Aug 15:59:52.866 # Server can't set maximum open files to 10032 because of OS error: Operation not permitted.
1:M 01 Aug 15:59:52.866 # Current maximum open files is 1024. maxclients has been reduced to 992 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
1:M 01 Aug 15:59:52.870 * Running mode=standalone, port=6379.
1:M 01 Aug 15:59:52.870 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
1:M 01 Aug 15:59:52.870 # Server initialized
1:M 01 Aug 15:59:52.870 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
1:M 01 Aug 15:59:52.870 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
1:M 01 Aug 15:59:52.870 * Ready to accept connections
^C1:signal-handler (1533139193) Received SIGINT scheduling shutdown...
1:M 01 Aug 15:59:53.472 # User requested shutdown...
1:M 01 Aug 15:59:53.472 * Saving the final RDB snapshot before exiting.
1:M 01 Aug 15:59:53.484 * DB saved on disk
1:M 01 Aug 15:59:53.484 # Redis is now ready to exit, bye bye...
```

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-08-02 17:11:29 -04:00
Samuel Karp
9665a2650a *: replace 3600 seconds with 1 hour
Signed-off-by: Samuel Karp <skarp@amazon.com>
2018-08-02 11:40:03 -07:00
Justin Terry (VM)
790c3a3663 Remove extra allocation in NewTask
Reorders the code so that it doesnt overwrite the previous allocation
when creating a NewTask via ctr.exe

Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2018-08-01 13:22:18 -07:00
Phil Estes
ed0e73422d
Merge pull request #2468 from dmcgowan/set-platform-on-unpack
Update client Image to have configurable platform
2018-07-31 11:56:09 -04:00
Phil Estes
4249f44d81
Merge pull request #2493 from dmcgowan/sync-lease-removal
Add sync option to lease removal
2018-07-31 11:31:55 -04:00
Stephen Day
920dc79b4d
Merge pull request #2504 from samuelkarp/ctr-t-metrics
ctr: add new metrics subcommand
2018-07-30 13:07:19 -07:00
Samuel Karp
9a34bb046a metrics: add optional json output
Signed-off-by: Samuel Karp <skarp@amazon.com>
2018-07-27 15:21:08 -07:00
Stephen Day
2a1bd7414b
oci: introduce WithSpecFromFile combinator
We introduce a WithSpecFromFile option combinator to allow creation
simpler creation of OCI specs from a file name. Often used as the first
option in a `SpecOpts` slice, it simplifies choosing between a local
file and the built-in default.

The code in `ctr run` has been updated to use the new option, with out
changing the order of operations or functionality present there.

Signed-off-by: Stephen Day <stephen.day@getcruise.com>
2018-07-27 14:25:42 -07:00
Samuel Karp
2c87d120df ctr: add new metrics subcommand
Signed-off-by: Samuel Karp <skarp@amazon.com>
2018-07-27 09:37:57 -07:00
Michael Crosby
26e2dd6754
Merge pull request #2425 from avagin/docker-fixes
task: allow to specify namespaces which are restored externally
2018-07-25 10:26:08 -04:00
Michael Crosby
0d52c71c80
Merge pull request #2474 from dmcgowan/lease-expiration
Improved lease management
2018-07-20 16:54:17 -04:00
Andrei Vagin
fc2fcf6b2a task: WithExit() doesn't have to overwrite existing options
Signed-off-by: Andrei Vagin <avagin@openvz.org>
2018-07-20 13:19:05 -07:00
Michael Crosby
17ab11a236 Fixes for runtimev2 and checkpoint restore
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-07-20 12:09:29 -04:00
Derek McGowan
94e132fd07
Add sync option on lease removal
Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2018-07-19 14:37:55 -07:00
Derek McGowan
00a99c0472
Add leases subcommand in ctr
Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2018-07-18 10:43:37 -07:00
Derek McGowan
3a916a0f67
Update client Image to have configurable platform
Separate Fetch and Pull commands in client to distinguish
between platform specific and non-platform specific operations.
`ctr images pull` with all platforms will now unpack all platforms.
`ctr content fetch` now supports platform flags.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2018-07-17 15:43:03 -07:00
Michael Crosby
da1b5470cd Runtime v2
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-07-17 10:21:29 -04:00
Derek McGowan
cce0a46c8a
Seed random on ctr and containerd startup
Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2018-07-12 17:51:55 -07:00
Danail Branekov
3cf3881fa4 Introduce plugins/list subcommand
`Ctr` interface follows the pattern `ctr <command> <subcommand>` except
for the `plugins` command which does not have subcommands. This feels
unnatural to certain users and they would expect that they can list
containerd plugins via `ctr plugins list`.

This commit implements their expectation so that `plugins` becomes a
command "group" and its `list` subcommand actually lists the plugins.

Signed-off-by: Danail Branekov <danailster@gmail.com>
2018-07-02 10:20:20 +03:00
Michael Crosby
08150bfe76 Update ttrpc for containerd repo
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-06-28 09:53:40 -04:00
Michael Crosby
ca204317ed
Merge pull request #2422 from crosbymichael/ctr-delete
Add cio.Load for loading io set
2018-06-27 08:46:18 -04:00
Michael Crosby
fdceb13b14 Add cio.Load for loading io set
This adds a `Load` Opt for cio to load a tasks io/fifos without
attaching or starting the copy routines.

It adds the load method in `ctr` by default so that fifos or other IO
are removed from disk on delete methods inbetween command runs.  It is
not the default for all task loads for backwards compat. and a user may
want to keep io around to reuse or if log files are used.

Fixes #2421

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-06-26 11:48:26 -04:00
Felix Abecassis
5dd22a20af Move ContainerFlags to "commands" package
Commit 05513284e7 exposed the "rootfs"
and "no-pivot" flags for the "containers" command, but it accidentally
removed them for "run" since package-level variables are initialized
before package-level init functions in golang. Hoisting these flags to
a package imported by both commands solves the problem.

Signed-off-by: Felix Abecassis <fabecassis@nvidia.com>
2018-06-20 18:33:59 -07:00
Phil Estes
df34eefa12
Merge pull request #2330 from crosbymichael/hpc
Add nvidia gpu support
2018-06-07 10:10:20 -04:00
Evan Hazlett
821c8eaa91
runtime/linux/shim -> runtime/shim
Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
2018-06-06 14:35:06 -04:00
Akihiro Suda
d88de4a34f content: change Writer/ReaderAt to take OCI
This change allows implementations to resolve the location of the actual data
using OCI descriptor fields such as MediaType.

No OCI descriptor field is written to the store.

No change on gRPC API.

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2018-06-01 11:51:43 +09:00
Derek McGowan
1e8b09cfc6
Merge pull request #2353 from ehazlett/process-runtime
linux -> runtime/linux
2018-05-30 10:06:36 -07:00
Michael Crosby
c7083eed5d
Merge pull request #2369 from dmcgowan/update-grpc
Update grpc to 1.12
2018-05-30 11:07:10 -04:00
Evan Hazlett
cae94b930d linux -> runtime/linux
Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
2018-05-30 09:23:10 -04:00
Derek McGowan
55afe3359a
Update grpc timeout and logger
Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2018-05-29 15:32:37 -07:00
Michael Crosby
ae4b78d1cc Move progress into pkg
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-05-22 13:32:25 -04:00
Michael Crosby
b949697a9c Add nvidia gpu support via libnvidia-container
This adds nvidia gpu support via the libnvidia-container project and
`nvidia-container-cli`.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-05-09 13:37:39 -04:00
Derek McGowan
f701b3b960
Fix race in ctr pull
Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2018-05-07 10:29:24 -07:00
Michael Crosby
e22c827cf5
Merge pull request #2323 from stevvooe/ping-snapshots-from-cli
cmd/snapshots: add gc.root to created snapshots
2018-05-04 13:27:44 -04:00
Tom Godkin
fc8bce59b9 Use user-specific temp directory if set
This allows non-privileged users to use containerd. This is part of a
larger track of work integrating containerd into Cloudfoundry's garden
with support for rootless.

[#156343575]

Signed-off-by: Claudia Beresford <cberesford@pivotal.io>
2018-05-04 10:27:58 +01:00
Stephen J Day
ed72059fac
cmd/snapshots: add gc.root to created snapshots
This adds gc.root label to snapshots created with prepare and commit via
the CLI. WIthout this, created snapshots get immediately garbage
collected. There may be a better solution but this seems to be a solid
stop gap.

We may also need to add more functionality around snapshot labeling for
the CLI but current use cases are unclear.

Signed-off-by: Stephen J Day <stevvooe@gmail.com>
2018-05-03 07:09:38 +02:00
Andrei Vagin
60daa414db Allow to checkpoint and restore a container with console
runc already supports this case, so we just need to run it with proper
options.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-04-28 01:06:42 +03:00
Derek McGowan
1a5e0df98f
Merge pull request #2305 from kolyshkin/context
Switch from x/net/context -> context
2018-04-25 10:44:22 -07:00
Michael Crosby
090687916d Correctly handle reading from events channel
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-04-25 11:21:22 -04:00
Kir Kolyshkin
bbe14f0a2e Switch from x/net/context to context
Since Go 1.7, context is a standard package, superceding the
"x/net/context". Since Go 1.9, the latter only provides a few type
aliases from the former. Therefore, it makes sense to switch to the
standard package.

This commit was generated by the following script (with a couple of
minor fixups to remove extra changes done by goimports):

	#!/bin/bash

	if [ $# -ge 1 ]; then
		FILES=$*
	else
		FILES=$(git ls-files \*.go | grep -vF ".pb.go" | grep -v
	^vendor/)
	fi

	for f in $FILES; do
		printf .
		sed -i -e 's|"golang.org/x/net/context"$|"context"|' $f
		goimports -w $f
		awk '	/^$/ {e=1; next;}
			/[[:space:]]"context"$/ {e=0;}
			{if (e) {print ""; e=0}; print;}' < $f > $f.new && \
				mv $f.new $f
		goimports -w $f
	done
	echo

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2018-04-24 14:33:34 -07:00
Julien Kassar
9d247718d7 Update ctr tasks list usage for quiet flag
Signed-off-by: Julien Kassar <github@kassisol.com>
2018-04-23 14:53:35 -04:00
Fernando Mayo
0a26b0fe43 ctr: fix --mount help message
Signed-off-by: Fernando Mayo <fermayo@gmail.com>
2018-04-17 18:29:33 -07:00
Justin Cormack
903191072e
Add --privileged option to ctr run
Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2018-04-04 13:25:42 +01:00
Michael Crosby
3e8e9d3ed7
Merge pull request #2223 from dmcgowan/with-lease-context
lease: pass in context to lease done function in client
2018-03-23 10:27:39 -04:00
Derek McGowan
43d0a5cb60
Pass in context to lease done function in client
Allows the client to choose the context to finish the lease.
This allows the client to switch contexts when the main context
used to the create the lease may have been cancelled.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2018-03-22 14:09:24 -07:00
Stephen J Day
903ee88368
cmd/ctr/app: remove redundant package name
Signed-off-by: Stephen J Day <stephen.day@docker.com>
2018-03-22 10:12:00 -07:00
Derek McGowan
a0b818e093
Merge pull request #2200 from jessvalarezo/multiarch-pulls
allow content to be pulled for specific platform(s), all platforms
2018-03-14 14:46:30 -07:00
Phil Estes
b307df2723
Merge pull request #2207 from jessvalarezo/ctr-task-d-update
ctr: allow for force kill when deleting task process
2018-03-14 03:41:23 -04:00
Lantao Liu
ea6a10c412 Add cri subcommand and add ctr/command package
Signed-off-by: Lantao Liu <lantaol@google.com>
2018-03-14 01:11:29 +00:00
Jess Valarezo
e343006b8f ctr: allow for force kill when deleting task process
Signed-off-by: Jess Valarezo <valarezo.jessica@gmail.com>
2018-03-13 14:58:31 -07:00
Stephen J Day
ae11d8c64b
cmd/ctr/images: add i alias for images command
Signed-off-by: Stephen J Day <stephen.day@docker.com>
2018-03-12 17:42:41 -07:00
Jess Valarezo
c3cf3d7822 allow content to be pulled for specific platform(s), all platforms
Signed-off-by: Jess Valarezo <valarezo.jessica@gmail.com>
2018-03-12 17:31:42 -07:00
Stephen Day
3013762fc5
Merge pull request #2203 from Random-Liu/support-in-process-integration
Support in process integration
2018-03-12 14:38:27 -07:00
Lantao Liu
1128b3d664 Add service plugin and support in process integration.
Signed-off-by: Lantao Liu <lantaol@google.com>
2018-03-12 18:03:50 +00:00
Stephen Day
5368984859
Merge pull request #2160 from ijc/ctr-run-unpack
ctr: unpack the image on run if necessary
2018-03-06 19:29:43 -08:00
Derek McGowan
2b6b99b4a1
Merge pull request #2184 from kunalkushwaha/oci-error
better image config parse error.
2018-03-05 10:29:02 -08:00
Akihiro Suda
05513284e7 ctr: add UNIX-specific flags to ctr c create
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2018-03-05 15:26:03 +09:00
Kunal Kushwaha
6ed4e9e106 better image config parse error.
compatible oci runtime version printed with parse error

Signed-off-by: Kunal Kushwaha <kushwaha_kunal_v7@lab.ntt.co.jp>
2018-03-05 14:04:08 +09:00
Ian Campbell
f48cc7d7fe ctr: unpack the image on run if necessary
Without this `ctr run` can fail with:

    ctr: parent snapshot sha256:70798fd80095f40b41baa5d107fb61532bfe494d96313fea01e8fcbf4e8743ee does not exist: not found

My image was produced by buildkit, which doesn't unpack (I think this makes
sense since buildkit doesn't know if I am going to run the image or export/push
it etc).

Signed-off-by: Ian Campbell <ian.campbell@docker.com>
2018-02-26 14:23:28 +00:00
Michael Crosby
d3a8055e2d Add --pid-file to ctr
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-02-20 15:10:50 -05:00
Kunal Kushwaha
b12c3215a0 Licence header added
Signed-off-by: Kunal Kushwaha <kushwaha_kunal_v7@lab.ntt.co.jp>
2018-02-19 10:32:26 +09:00
Phil Estes
e4e53bf486
Add --with-ns flag to ctr run/create
Adds a useful flag to `ctr` to enable joining any existing Linux
namespaces for any namespace types (network, pid, ipc, etc.) using the
existing With helper in the oci package.

Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com>
2018-02-16 15:23:04 -05:00
Michael Crosby
78bd07afef
Merge pull request #1746 from AkihiroSuda/split-differ-interface
diff: resplit Applier from Differ
2018-02-05 09:18:56 -05:00
Michael Crosby
5f89502a24
Merge pull request #1790 from jessvalarezo/ctr-c-create
ctr: add container create cmd and config flag
2018-01-29 17:19:14 -05:00
Derek McGowan
b763777288
diff: rename differ to comparer
Remove combined interface and split implementations.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2018-01-26 16:32:09 -08:00
Phil Estes
d4fb0709c9
Add error return for missing params in ctr images
For missing required parameters adds error return before attempting any
actions to `ctr images` commands.

Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com>
2018-01-26 09:14:13 -05:00
Jess Valarezo
2c9ce2e693 ctr: add container create, config flag for spec
Signed-off-by: Jess Valarezo <valarezo.jessica@gmail.com>
2018-01-25 17:16:13 -08:00
Darren Stahl
dcff993653 Update Windows runtime to use snapshotter and differ layers
This changes the Windows runtime to use the snapshotter and differ
created layers, and updates the ctr commands to use the snapshotter and differ.

Signed-off-by: Darren Stahl <darst@microsoft.com>
2018-01-23 14:40:24 -08:00
Phil Estes
d7efcbc083
Merge pull request #2036 from stevvooe/use-buffer-pools
archive, cio, cmd, linux: use buffer pools
2018-01-23 15:00:41 -05:00
Phil Estes
dc5964ccc2
Merge pull request #2037 from pauldotknopf/master
Made a public method to set environment variables and mounts for containers.
2018-01-22 17:05:26 -05:00
Stephen J Day
cd72819b53
archive, cio, cmd, linux: use buffer pools
To avoid buffer bloat in long running processes, we try to use buffer
pools where possible. This is meant to address shim memory usage issues,
but may not be the root cause.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2018-01-22 13:52:06 -08:00
Paul Knopf
b4c3cd7640
Add WithEnv and WithMount oci options
Signed-off-by: Paul Knopf <pauldotknopf@gmail.com>
2018-01-22 16:35:31 -05:00
Akihiro Suda
507a149488 cio: add WithFIFODir opt
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2018-01-18 14:33:56 +09:00
Akihiro Suda
1167035be3 ctr: promote cOpts over opts, as oci.WithImageConfig requires snapshot
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2018-01-11 14:04:11 +09:00
Daniel Nephin
184bc25629 Add unconvert linter
This linter checks for unnecessary type convertions.

Some convertions are whitelisted because their type is different
on 32bit platforms

Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2018-01-09 17:36:44 -05:00
Kenfe-Mickael Laventure
0cc79a6ff6
Add no-pivot flag to ctr
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2018-01-09 07:48:30 -08:00
Michael Crosby
4e755ad383
Merge pull request #1947 from jessvalarezo/ctr-snapshot-diff
ctr: snapshots diff command
2018-01-03 11:34:29 -05:00
Jess Valarezo
625eb5e661 ctr: snapshots diff command
Signed-off-by: Jess Valarezo <valarezo.jessica@gmail.com>
2018-01-02 21:18:12 -05:00
Michael Crosby
399e3c57c3 Change ctr help for mount from dest to dst
dest is not valid, only destination and dst

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-12-15 16:40:25 -05:00
Phil Estes
afbbe43745
Merge pull request #1895 from dnephin/refactor-cio
Refactor cio package
2017-12-15 14:44:44 -05:00
Stephen J Day
9aeeefae55
cmd/ctr: stablize output of snapshot tree
Preserves the order of the tree output between each execution. Slightly
refactored the behavior to be more "object oriented".

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-12-12 14:50:05 -08:00
Daniel Nephin
7d4337e738 Reduce the number of IO constructors
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2017-12-11 15:07:09 -05:00
Derek McGowan
40c67fdf78
Merge pull request #1880 from AkihiroSuda/refactor-importer
importer: refactor and fix GC
2017-12-04 20:56:26 -08:00
Akihiro Suda
63401970c7 importer: refactor
- Use lease API (previoisly, GC was not supported)
- Refactored interfaces for ease of future Docker v1 importer support

For usage, please refer to `ctr images import --help`.

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2017-12-05 12:48:32 +09:00
Stephen J Day
1710fe9b95
cmd/ctr: move log messages to debug
Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-12-01 13:57:54 -08:00
Jess Valarezo
9885edfc44 rename snapshot->snapshots pkg
Signed-off-by: Jess Valarezo <valarezo.jessica@gmail.com>
2017-11-29 14:55:02 -08:00
Jess Valarezo
61c8fe2307 ctr: snapshot->snapshots cmd, add aliases
Signed-off-by: Jess Valarezo <valarezo.jessica@gmail.com>
2017-11-29 14:34:02 -08:00
Akihiro Suda
7f95b9f987 ctr: add EnvVar CONTAINERD_SNAPSHOTTER for --snapshotter
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2017-11-29 19:11:10 +09:00
Phil Estes
2556c594ec
Merge pull request #1767 from stevvooe/ttrpc-shim
linux/shim: reduce memory overhead by using ttrpc
2017-11-28 12:43:41 -05:00
Stephen Day
372cdfac3b
Merge pull request #1638 from dmcgowan/gc-policy
gc: add policy plugin
2017-11-27 18:20:10 -08:00
Daniel Nephin
cdf62f69a1 Fix usage of oci in other packages.
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2017-11-27 16:16:17 -05:00
Daniel Nephin
0103d14b47 Fix ctr events
add import to register event types with grpc

Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2017-11-24 14:28:44 -05:00
Stephen J Day
e8f52c35ce
linux/shim: reduce memory overhead by using ttrpc
By replacing grpc with ttrpc, we can reduce total memory runtime
requirements and binary size. With minimal code changes, the shim can
now be controlled by the much lightweight protocol, reducing the total
memory required per container.

When reviewing this change, take particular notice of the generated shim
code.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-11-22 12:21:48 -08:00
Daniel Nephin
f74862a0dd Add structcheck, unused, and varcheck linters.
Warn on unused and dead code

Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2017-11-21 11:14:37 -05:00
Derek McGowan
3f1a61f76a
Add synchronous image delete
Synchronous image delete provides an option image delete to wait
until the next garbage collection deletes after an image is removed
before returning success to the caller.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-11-20 17:08:35 -08:00
Daniel Nephin
298dabc6c2 Move io.go into cio package
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2017-11-17 17:04:45 -05:00
Stephen J Day
c5022ad92d
protobuf: use the gogo/types package for empty
Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-11-15 19:08:54 -08:00
Stephen Day
571c002ef6
Merge pull request #1755 from AkihiroSuda/fix-ctr-snapshot-args
ctr: fix args
2017-11-14 17:55:14 -08:00
Akihiro Suda
5eff92d1ba ctr: fix args
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2017-11-15 01:34:12 +00:00
Stephen Day
f9933e9f96
Merge pull request #1742 from jessvalarezo/ctr-task-kill
ctr: update task kill to take exec-id
2017-11-13 13:53:26 -08:00
Michael Crosby
92ca22c997
Merge pull request #1735 from estesp/image-rm-feedback
Fix output on ctr images rm to show actual feedback
2017-11-13 14:18:12 -05:00
Jess Valarezo
1966f9f1b7 ctr: update task kill to take exec-id
Signed-off-by: Jess Valarezo <valarezo.jessica@gmail.com>
2017-11-13 10:47:15 -08:00
Phil Estes
08760757ed
Fix output on ctr images rm to show actual feedback
Currently the output for a non-existent image reference and a valid
image reference is exactly the same on `ctr images remove`. Instead of
outputting the target ref input, if it is "not found" we should alert
the user in case of a mispelling, but continue not to make it a failure
for the command (given it supports multiple ref entries)

Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com>
2017-11-10 15:21:27 -05:00
Jess Valarezo
807f4d2ec7 expose exec-id on ctr task ps
Signed-off-by: Jess Valarezo <valarezo.jessica@gmail.com>
2017-11-10 11:38:51 -08:00
Victor Vieux
f8a536ed6a Add S to PLATFORM in images & plugins list
Signed-off-by: Victor Vieux <victorvieux@gmail.com>
2017-11-08 10:43:12 -08:00
Sebastiaan van Stijn
65d5b8b937
Align version output and minor code cleanup
This patch changes the output of `ctr version` to align version and revision.
It also changes `.Printf()` to `.Println()`, to make the code slightly easier
to read.

Before this change:

    $ ctr version
    Client:
      Version: v1.0.0-beta.2-132-g564600e.m
      Revision: 564600ee79aefb0f24cbcecc90d4388bd0ea59de.m

    Server:
      Version: v1.0.0-beta.2-132-g564600e.m
      Revision: 564600ee79aefb0f24cbcecc90d4388bd0ea59de.m

With this patch applied:

    $ ctr version
    Client:
      Version:  v1.0.0-beta.2-132-g564600e.m
      Revision: 564600ee79aefb0f24cbcecc90d4388bd0ea59de.m

    Server:
      Version:  v1.0.0-beta.2-132-g564600e.m
      Revision: 564600ee79aefb0f24cbcecc90d4388bd0ea59de.m

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2017-11-03 17:49:23 +01:00
Stephen J Day
0a1a13448b
defaults: add package to contain server defaults
To reduce the binary size of containerd, we no longer import the
`server` package for only a few defaults. This reduces the size of `ctr`
by 2MB. There are probably other gains elsewhere.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-11-02 13:59:34 -07:00
Jess Valarezo
864b16a2cb ctr: alphabetize commands, rename signals
Signed-off-by: Jess Valarezo <valarezo.jessica@gmail.com>
2017-10-31 11:57:49 -07:00
Jess Valarezo
f654b7b71e ctr: move pprof to commands package
Signed-off-by: Jess Valarezo <valarezo.jessica@gmail.com>
2017-10-31 11:57:49 -07:00
Jess Valarezo
a827a17f1d ctr: move shim to commands
Signed-off-by: Jess Valarezo <valarezo.jessica@gmail.com>
2017-10-31 11:57:49 -07:00
Jess Valarezo
c3b70f1d0b ctr: move tasks, run to commands package
Signed-off-by: Jess Valarezo <valarezo.jessica@gmail.com>
2017-10-31 11:57:41 -07:00
Phil Estes
ff904841f9
Merge pull request #1668 from jessvalarezo/image-unpack-check
client: Add helper function which checks if an image is unpacked
2017-10-31 10:23:08 -04:00
Phil Estes
9f5b97c510
Merge pull request #1698 from crosbymichael/task-ls
Move task list to separate command
2017-10-30 21:30:02 -04:00
Phil Estes
8bbf8d892a
Merge pull request #1693 from jessvalarezo/ctr-refactor-fourth-pass
ctr: move more commands
2017-10-30 21:29:24 -04:00
Jess Valarezo
1552ee23da client: Add helper function which checks if an image is unpacked
Signed-off-by: Jess Valarezo <valarezo.jessica@gmail.com>
2017-10-30 16:33:54 -07:00
Jess Valarezo
7a1d709cc9 ctr: remove apply command
* in its current state, apply command should not be in ctr

Signed-off-by: Jess Valarezo <valarezo.jessica@gmail.com>
2017-10-30 14:46:44 -07:00
Jess Valarezo
e4da49c44c ctr: move unpack to snapshot command
Signed-off-by: Jess Valarezo <valarezo.jessica@gmail.com>
2017-10-30 13:23:36 -07:00
Jess Valarezo
456d3f4475 ctr: move push and pull to images command
Signed-off-by: Jess Valarezo <valarezo.jessica@gmail.com>
2017-10-30 13:23:36 -07:00
Jess Valarezo
b58e4fc2ed ctr: move fetch,fetch-object,push-object to content
Signed-off-by: Jess Valarezo <valarezo.jessica@gmail.com>
2017-10-30 13:23:06 -07:00
Michael Crosby
91597bc6c3 Move task list to separate command
This keeps the semantics the same as the other commands to only list
containers, tasks, images by calling the list subcommand.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-10-30 15:01:00 -04:00
Michael Crosby
b93bd0cfec
Merge pull request #1676 from AkihiroSuda/null-io-fix
ctr: error if tty && nullIO
2017-10-30 10:10:22 -04:00
Akihiro Suda
e0da28acc4 ctr: error if tty && nullIO
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2017-10-29 23:58:57 +09:00
Jess Valarezo
16855eedf7 ctr: move resolver to commands package
Signed-off-by: Jess Valarezo <valarezo.jessica@gmail.com>
2017-10-26 16:31:58 -04:00
Jess Valarezo
ffd0d2ef58 ctr: move signals to commands package
Signed-off-by: Jess Valarezo <valarezo.jessica@gmail.com>
2017-10-26 16:31:23 -04:00
Jess Valarezo
8540587b37 ctr: move events command
Signed-off-by: Jess Valarezo <valarezo.jessica@gmail.com>
2017-10-25 22:21:57 -04:00
Jess Valarezo
fdb6859921 ctr: move namespaces command
Signed-off-by: Jess Valarezo <valarezo.jessica@gmail.com>
2017-10-25 22:00:14 -04:00
Jess Valarezo
750fd89b38 ctr: move snapshot command
Signed-off-by: Jess Valarezo <valarezo.jessica@gmail.com>
2017-10-25 21:23:41 -04:00
Jess Valarezo
0895dbe932 ctr: move content command
Signed-off-by: Jess Valarezo <valarezo.jessica@gmail.com>
2017-10-25 21:16:44 -04:00
Jess Valarezo
f980cc197e ctr: move images command
Signed-off-by: Jess Valarezo <valarezo.jessica@gmail.com>
2017-10-25 21:08:00 -04:00
Jess Valarezo
47fae4dd17 ctr: move containers command
Signed-off-by: Jess Valarezo <valarezo.jessica@gmail.com>
2017-10-25 21:07:54 -04:00
Michael Crosby
ae995bc7b3 Move plugins command
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-10-25 11:22:59 -04:00
Michael Crosby
2dac1b6963 Move version command into package
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-10-25 11:14:09 -04:00
Michael Crosby
4743f1fc4c Move NewClient and AppContext to commands pkg
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-10-25 11:10:00 -04:00
Jess Valarezo
a19a20303a ctr: add commands package with shared utility functions
Signed-off-by: Jess Valarezo <valarezo.jessica@gmail.com>
2017-10-23 17:40:18 -07:00
Michael Crosby
9f76083a8f Refactor newClient in ctr
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-10-23 13:38:15 -04:00
Michael Crosby
edf4114d55 Merge pull request #1673 from qingyunha/ctr
ctr use client's underlying service
2017-10-23 10:42:25 -04:00
Tao Qingyun
61121024c1 ctr use client's underlying service
Signed-off-by: Tao Qingyun <845767657@qq.com>
2017-10-23 20:22:54 +08:00
Michael Crosby
c7dc795455 [ctr] add --detach to run
This allows the user to detach from the container after it has started.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-10-19 15:13:38 -04:00
Michael Crosby
2e004086cf [ctr] Add --null-io to ctr run/start
This allows all task io to be redirected to /dev/null

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-10-19 15:01:33 -04:00
Michael Crosby
e4c6bf3b5e Remove default filter from ctr
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-10-17 17:10:03 -04:00
Michael Crosby
e201be5196 Create checkpointed image in client
Allow a user provided name for the checkpoint as well as a default
generated name for the checkpoint image.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-10-17 15:12:04 -04:00
Jacob Wen
abbec62620 cmd/ctr: create an image for checkpoint
This allows one to manage the checkpoints by using the `ctr image`
command.

The image is created with label "containerd.io/checkpoint". By
default, it is not included in the output of `ctr images ls`.
We can list the images by using the following command:
$ ctr images ls labels.containerd.\"io/checkpoint\"==true

Fixes #1026

Signed-off-by: Jacob Wen <jian.w.wen@oracle.com>
2017-10-17 11:25:37 -04:00
Derek McGowan
e378196505
Add snapshot label command to ctr
Allows easier debugging of snapshots using labels

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-10-16 11:54:01 -07:00
Jess Valarezo
830e0ea339 Change hcsshimopts to hcsshimtypes package
Signed-off-by: Jess Valarezo <valarezo.jessica@gmail.com>
2017-10-11 11:42:07 -07:00
Derek McGowan
d9db1d112d
Refactor differ into separate package
Add differ options and package with interface.
Update optional values on diff interface to use options.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-10-11 10:02:29 -07:00
Stephen J Day
0e72ce5c5b
services/introspection: implement plugin reporting
With this change, we integrate all the plugin changes into the
introspection service.

All plugins can be listed with the following command:

```console
$ ctr plugins
TYPE                            ID             PLATFORM       STATUS
io.containerd.content.v1        content        -              ok
io.containerd.metadata.v1       bolt           -              ok
io.containerd.differ.v1         walking        linux/amd64    ok
io.containerd.grpc.v1           containers     -              ok
io.containerd.grpc.v1           content        -              ok
io.containerd.grpc.v1           diff           -              ok
io.containerd.grpc.v1           events         -              ok
io.containerd.grpc.v1           healthcheck    -              ok
io.containerd.grpc.v1           images         -              ok
io.containerd.grpc.v1           namespaces     -              ok
io.containerd.snapshotter.v1    btrfs          linux/amd64    error
io.containerd.snapshotter.v1    overlayfs      linux/amd64    ok
io.containerd.grpc.v1           snapshots      -              ok
io.containerd.monitor.v1        cgroups        linux/amd64    ok
io.containerd.runtime.v1        linux          linux/amd64    ok
io.containerd.grpc.v1           tasks          -              ok
io.containerd.grpc.v1           version        -              ok
```

There are few things to note about this output. The first is that it is
printed in the order in which plugins are initialized. This useful for
debugging plugin initialization problems. Also note that even though the
introspection GPRC api is a itself a plugin, it is not listed. This is
because the plugin takes a snapshot of the initialization state at the
end of the plugin init process. This allows us to see errors from each
plugin, as they happen. If it is required to introspect the existence of
the introspection service, we can make modifications to include it in
the future.

The last thing to note is that the btrfs plugin is in an error state.
This is a common state for containerd because even though we load the
plugin, most installations aren't on top of btrfs and the plugin cannot
be used. We can actually view this error using the detailed view with a
filter:

```console
$ ctr plugins --detailed id==btrfs
Type:          io.containerd.snapshotter.v1
ID:            btrfs
Platforms:     linux/amd64
Exports:
               root      /var/lib/containerd/io.containerd.snapshotter.v1.btrfs
Error:
               Code:        Unknown
               Message:     path /var/lib/containerd/io.containerd.snapshotter.v1.btrfs must be a btrfs filesystem to be used with the btrfs snapshotter
```

Along with several other values, this is a valuable tool for evaluating the
state of components in containerd.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-10-10 17:29:24 -07:00
Jess
061c719209 ListPids returns process ID and other info
Signed-off-by: Jess <jessica.valarezo@docker.com>
2017-10-10 22:57:15 +00:00
Michael Crosby
fa9e9bdf46 Fetch current container info before operations
This makes sure the client is always in sync with the server before
performing any type of operations on the container metadata.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-10-04 15:29:57 -04:00
Kenfe-Mickaël Laventure
ec43dc2b46 Merge pull request #1592 from AkihiroSuda/workdir2
ctr run: add --cwd
2017-10-04 09:17:21 -07:00
Akihiro Suda
b26e2e781c ctr run: add --cwd
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2017-10-04 04:40:08 +00:00
Stephen J Day
c555df54c0
images: support checking status of image content
The `Check` function returns information about an image's content components
over a content provider. From this information, one can tell which content is
required, present or missing to run an image.

The utility can be demonstrated with the `check` command:

```console
$ ctr images check
REF                               TYPE                                                      DIGEST                                                                  STATUS            SIZE
docker.io/library/alpine:latest   application/vnd.docker.distribution.manifest.list.v2+json sha256:f006ecbb824d87947d0b51ab8488634bf69fe4094959d935c0c103f4820a417d incomplete (1/2)  1.5 KiB/1.9 MiB
docker.io/library/postgres:latest application/vnd.docker.distribution.manifest.v2+json      sha256:2f8080b9910a8b4f38ff5a55a82e77cb43d88bdbb16d723c71d18493590832e9 complete (13/13)  99.3 MiB/99.3 MiB
docker.io/library/redis:alpine    application/vnd.docker.distribution.manifest.v2+json      sha256:e633cded055a94202e4ccccb8125b7f383cd6ee56527ab890db643383a2647dd incomplete (6/7)  8.1 MiB/10.0 MiB
docker.io/library/ubuntu:latest   application/vnd.docker.distribution.manifest.list.v2+json sha256:60f835698ea19e8d9d3a59e68fb96fb35bc43e745941cb2ea9eaf4ba3029ed8a unavailable (0/?) 0.0 B/?
docker.io/trollin/busybox:latest  application/vnd.docker.distribution.manifest.list.v2+json sha256:54a6424f7a2d5f4f27b3d69e5f9f2bc25fe9087f0449d3cb4215db349f77feae complete (2/2)    699.9 KiB/699.9 KiB
```

The above shows us that we have two incomplete images and one that is
unavailable. The incomplete images are those that we know the complete
size of all content but some are missing. "Unavailable" means that the
check could not get enough information about the image to get its full
size.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-10-03 15:19:22 -07:00
Michael Crosby
33e974ce99 Merge pull request #1577 from crosbymichael/lint-1
Update files based on go lint
2017-10-02 10:57:19 -04:00
Michael Crosby
f43b7acfd2 Update files based on go lint
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-10-02 10:15:28 -04:00
Tobias Klauser
727fd599fb ctr: remove SIGUNUSED from signal map
The SIGUNUSED constant was removed from golang.org/x/sys/unix in
https://go-review.googlesource.com/61771 as it is also removed from the
respective glibc headers.

This means the command

  ctr tasks kill SIGUNUSED ...

will no longer work. However, the same effect can be achieved with

  ctr tasks kill SIGSYS ...

as SIGSYS has the same value as SIGUNUSED used to have.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-10-02 15:10:31 +02:00
Akihiro Suda
27023c7fa2 readonly: pass RW rootfs to runtime, and let the runtime remount it as RO
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2017-09-29 06:20:26 +00:00
Kenfe-Mickael Laventure
df82159f4d
client: Allow setting image labels on Pull() and Import()
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2017-09-27 15:05:34 -07:00
Akihiro Suda
2a648136a9 ctr: add ctr images ls --quiet
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2017-09-26 09:43:10 +00:00
Stephen Day
df896c92e7 Merge pull request #1528 from jessvalarezo/labels-validate
Labels are consistently validated across services.
2017-09-22 10:33:17 -07:00
Allen Sun
d5b027c94b make command help display consistent
Signed-off-by: Allen Sun <shlallen1990@gmail.com>
2017-09-22 15:44:26 +08:00
Jess Valarezo
18c4322bb3 Labels are consistently validated across services
* The combined size of a key/value pair cannot exceed 4096 bytes

Signed-off-by: Jess Valarezo <valarezo.jessica@gmail.com>
2017-09-21 15:11:46 -07:00
Derek McGowan
eef47ffad3
Add platform filtering on children handler
Fixes pulling of multi-arch images by limiting the expansion
of the index by filtering to the current default platform.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-09-20 15:18:18 -07:00
Phil Estes
ef5f2025aa Merge pull request #1533 from stevvooe/specifier-default
platforms: provide simpler function for common use
2017-09-20 15:15:12 -04:00
Stephen J Day
9163377123
platforms: provide simpler function for common use
Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-09-20 11:56:59 -07:00
Michael Crosby
d22160c28e Vendor typeurl package
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-09-19 09:43:55 -04:00
Derek McGowan
46ded63f2d
Support for multi-arch image unpacking
Resolves the platform on multi-arch manifests during unpack and config resolving.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-09-14 09:32:37 -07:00
Stephen J Day
ea8adf9021
cmd/ctr: show resolved image platform
Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-09-13 12:41:55 -07:00
Michael Crosby
2cfd7df257 Merge pull request #1456 from ijc/ctr-list-no-labels
ctr: drop labels from `ctr containers` subcommand list
2017-09-07 11:07:05 -04:00
Kenfe-Mickaël Laventure
e1eeb0e0a2 Merge pull request #1475 from dmcgowan/content-commit-context
Add context to content commit
2017-09-06 11:04:31 -07:00
Derek McGowan
9613acb2ed
Add context to content commit
Content commit is updated to take in a context, allowing
content to be committed within the same context the writer
was in. This is useful when commit may be able to use more
context to complete the action rather than creating its own.
An example of this being useful is for the metadata implementation
of content, having a context allows tests to fully create
content in one database transaction by making use of the context.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-09-06 10:19:12 -07:00
Stephen Day
378e3343fe Merge pull request #1362 from AkihiroSuda/ctr-snapshot-info
ctr: add `ctr snapshot info <key>`
2017-09-01 14:25:25 -07:00
Michael Crosby
5614e9c7b3 Wait on exec process not task
Fixes #1449

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-09-01 11:51:45 -04:00
Akihiro Suda
053deb5ce2 ctr: net-host: bind-mount host /etc/{hosts,resolv.conf}
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2017-09-01 07:16:31 +00:00
Akihiro Suda
fef7f3addc ctr: add ctr snapshot info <key>
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2017-09-01 04:41:34 +00:00
Ian Campbell
94b0d0ecd0 ctr: drop labels from ctr containers subcommand list
The labels can be very long (e.g. cri-containerd stores a large JSON metadata
blob as `io.cri-containerd.container.metadata`) which renders the output
useless due to all the line wrapping etc.

The information is still available in `ctr containers info «name»`.

Signed-off-by: Ian Campbell <ian.campbell@docker.com>
2017-08-31 23:42:21 +01:00
Kenfe-Mickael Laventure
42b131c1f3
Allow setting runtime options when using WithRuntime()
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2017-08-29 10:03:51 -07:00
Michael Crosby
ed6b8fb0aa Add KillOpts for killing all processes
Fixes #1431

This adds KillOpts so that a client can specify when they want to kill a
single process or all the processes inside a container.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-08-28 13:29:47 -04:00
Michael Crosby
f66f0fb7a0 Update windows SpecOpts in tests
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-08-24 10:32:16 -04:00
Michael Crosby
c601606f84 Move spec generation to Container Create
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-08-24 10:32:16 -04:00
Michael Crosby
fa14f2ef3a Add context and client to SpecOpts
In order to do more advanced spec generation with images, snapshots,
etc, we need to inject the context and client into the spec generation
code.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-08-24 10:32:16 -04:00
Kenfe-Mickael Laventure
7f6c487031
go-client: Return an ExitStatus struct when calling process.Delete()
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2017-08-23 10:32:51 -07:00
Phil Estes
4712ed5390
Fix snapshot ctr command to use default
After the rework of server-side defaults, the `ctr snapshot` command
stopped working due to no default snapshotter.

Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com>
2017-08-22 11:54:37 -07:00
Brian Goff
6ab99edb71 Convert ExitStatus to use fn to get details
Instead of requiring callers to read the struct fields to check for an
error, provide the exit results via a function instead which is more
natural.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2017-08-22 10:48:44 -04:00
Brian Goff
026896ac4c Make Wait() async
In all of the examples, its recommended to call `Wait()` before starting
a process/task.
Since `Wait()` is a blocking call, this means it must be called from a
goroutine like so:

```go
statusC := make(chan uint32)
go func() {
  status, err := task.Wait(ctx)
  if err != nil {
    // handle async err
  }

  statusC <- status
}()

task.Start(ctx)
<-statusC
```

This means there is a race here where there is no guarentee when the
goroutine is going to be scheduled, and even a bit more since this
requires an RPC call to be made.
In addition, this code is very messy and a common pattern for any caller
using Wait+Start.

Instead, this changes `Wait()` to use an async model having `Wait()`
return a channel instead of the code itself.
This ensures that when `Wait()` returns that the client has a handle on
the event stream (already made the RPC request) before returning and
reduces any sort of race to how the stream is handled by grpc since we
can't guarentee that we have a goroutine running and blocked on
`Recv()`.

Making `Wait()` async also cleans up the code in the caller drastically:

```go
statusC, err := task.Wait(ctx)
if err != nil {
  return err
}

task.Start(ctx)

status := <-statusC
if status.Err != nil {
  return err
}
```

No more spinning up goroutines and more natural error
handling for the caller.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2017-08-22 09:33:07 -04:00
Zhang Wei
14fe2d5f20 Add newline char to avoid mix of logs
Add a '\n' after "unpacking xxx..." to avoid mix of logs such as:

```
unpacking sha256:a7776895af32e34b1fef997e26c79fa988b40c5cf2a3fb48dc22e0584b648d82...DEBU[0005]
Extraction not needed, layer snapshot exists
DEBU[0005] Extraction not needed, layer snapshot exists
DEBU[0005] Extraction not needed, layer snapshot exists
DEBU[0005] Extraction not needed, layer snapshot exists
DEBU[0005] Extraction not needed, layer snapshot exists
DEBU[0005] Extraction not needed, layer snapshot exists
done
```

After this commit:

```
unpacking sha256:a7776895af32e34b1fef997e26c79fa988b40c5cf2a3fb48dc22e0584b648d82...
DEBU[0008] Extraction not needed, layer snapshot exists
DEBU[0008] Extraction not needed, layer snapshot exists
DEBU[0008] Extraction not needed, layer snapshot exists
DEBU[0008] Extraction not needed, layer snapshot exists
DEBU[0008] Extraction not needed, layer snapshot exists
DEBU[0008] Extraction not needed, layer snapshot exists
done
```

Signed-off-by: Zhang Wei <zhangwei555@huawei.com>
2017-08-20 21:03:18 +08:00
Akihiro Suda
e03ecd30a7 ctr: add ctr snapshot view
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2017-08-16 08:40:11 +00:00
Akihiro Suda
ca352220b5 ctr: fix ctr snapshot commit
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2017-08-15 08:14:54 +00:00
Michael Crosby
a888587cc4 Set runtime on container from ctr
Set the missing `--runtime` flag when using ctr for new containers

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-08-10 11:38:36 -04:00
Michael Crosby
17d7a5c65b Merge pull request #1321 from stevvooe/refactor-snapshot-commands
cmd/snapshot: follow conventions from Snapshotter
2017-08-10 10:08:38 -04:00
Stephen J Day
cea1d337c2
cmd/snapshot: follow conventions from Snapshotter
The argument order, naming and behavior of the snapshots command didn't
really follow any of the design constraints or conventions of the
`Snapshotter` interface. This brings the command into line with that
interface definition.

The `snapshot archive` command has been removed as it requires more
thought on design to correctly emit diffs.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-08-09 17:22:33 -07:00
Stephen Day
e6ba48f25c Merge pull request #1257 from stevvooe/content-changes
content: remove Provider.Reader
2017-08-09 17:12:44 -07:00
Stephen J Day
8be340e37b
content: remove Provider.Reader
After some analysis, it was found that Content.Reader was generally
redudant to an io.ReaderAt. This change removes `Content.Reader` in
favor of a `Content.ReaderAt`. In general, `ReaderAt` can perform better
over interfaces with indeterminant latency because it avoids remote
state for reads. Where a reader is required, a helper is provided to
convert it into an `io.SectionReader`.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-08-09 14:32:28 -07:00
Tobias Klauser
4a6a2b9db0 Switch from package syscall to golang.org/x/sys
The syscall package is locked down and the comment in [1] advises to
switch code to use the corresponding package from golang.org/x/sys. Do
so and replace usage of package syscall with package
golang.org/x/sys/{unix,windows} where applicable.

  [1] https://github.com/golang/go/blob/master/src/syscall/syscall.go#L21-L24

This will also allow to get updates and fixes for syscall wrappers
without having to use a new go version.

Errno, Signal and SysProcAttr aren't changed as they haven't been
implemented in x/sys/. Stat_t from syscall is used if standard library
packages (e.g. os) require it. syscall.ENOTSUP, syscall.SIGKILL and
syscall.SIGTERM are used for cross-platform files.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-08-09 13:41:16 +02:00
Phil Estes
8ebbd1cdf9
Delete command should require at least one container ID
Also fix help/usage to reveal delete accepts multiple container IDs.

Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com>
2017-08-08 11:13:23 -04:00
Derek McGowan
738c22a756 Merge pull request #1299 from crosbymichael/ctr
Update ctr containers and tasks command
2017-08-07 13:32:03 -07:00
Michael Crosby
2fb2168bae Merge pull request #1224 from epilatow/solaris.cc.20170719.0
Add solaris build support
2017-08-07 16:15:07 -04:00
Edward Pilatowicz
56c1f5c184 Add solaris build support
Signed-off-by: Edward Pilatowicz <edward.pilatowicz@oracle.com>
2017-08-07 12:40:21 -07:00
Michael Crosby
00288bcb58 Update ctr containers and tasks command
This moves container and tasks commands under the containers and tasks
top level commands.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-08-07 14:45:21 -04:00
Michael Crosby
b20fd92a13 Merge pull request #1298 from miaoyq/add-start-cmd
Add `start` subcommand in `ctr`.
2017-08-07 10:21:35 -04:00
Michael Crosby
60f7eee27b Merge pull request #1275 from mlaventure/travis-ineffassign
Enable ineffassign in CI
2017-08-07 09:21:53 -04:00
Yanqiang Miao
ac72bbab26 Add start subcommand in ctr.
Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>
2017-08-05 09:39:11 +08:00
Michael Crosby
de7afd8aa8 Merge pull request #1293 from dmcgowan/fix-snapshotter-run
Fix ctr run bug when snapshotter is provided
2017-08-04 17:07:49 -04:00
Derek McGowan
5a74a46d42
Fix bug where snapshots got created with wrong snapshotter
Snapshotters for run must be created with requested snapshotter.
The order of the options is important to ensure that the snapshotter
is set before the snapshots are created.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-08-04 13:32:33 -07:00
Kenfe-Mickael Laventure
16f6e0944a
Do not touch grpc logger from within the packages
Libraries should not make process wide changes unless requested to.

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2017-08-04 10:11:46 -07:00
Phil Estes
7e0063320c Merge pull request #1282 from AkihiroSuda/dismiss-progressbar-on-debug
ctr: dismiss progressbar on --debug
2017-08-04 11:51:17 -04: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
829845d268
Fix ineffassign warnings
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2017-08-03 08:27:15 -07:00
Akihiro Suda
b45fb98530 ctr: dismiss progressbar on --debug
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2017-08-03 09:35:52 +00: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
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
Stephen Day
20fa6aee2e Merge pull request #1182 from AkihiroSuda/rootfs
client, ctr: allow specifying unmanaged rootfs dir
2017-07-28 10:56:25 -07:00
Michael Crosby
183a6ca888 Merge pull request #1013 from AkihiroSuda/oci-export
client: add Import() and Export() for importing/exporting image in OCI format
2017-07-28 09:22:22 -04:00
Akihiro Suda
b518f11dba client: add Import() and Export() for importing/exporting image in OCI format
Export as a tar (Note: "-" can be used for stdout):

    $ ctr images export /tmp/oci-busybox.tar docker.io/library/busybox:latest

Import a tar (Note: "-" can be used for stdin):

    $ ctr images import foo/new:latest /tmp/oci-busybox.tar

Note: media types are not converted at the moment: e.g.
  application/vnd.docker.image.rootfs.diff.tar.gzip
  -> application/vnd.oci.image.layer.v1.tar+gzip

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2017-07-28 04:47:53 +00:00
Akihiro Suda
752d253f40 client, ctr: allow specifying unmanaged rootfs dir
e.g. ctr run -t --rm --rootfs /tmp/busybox-rootfs foo /bin/sh
(--rm removes the container but does not remove rootfs dir, of course)

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2017-07-28 04:45:04 +00:00
Stephen J Day
83ac874886
cmd/ctr: allow deleting multiple containers at once
Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-07-27 15:30:35 -07:00
Michael Crosby
b84817a29c Merge pull request #1246 from stevvooe/events-refactor
events: refactor event distribution
2017-07-26 08:31:12 -04:00
Derek McGowan
73bec3edea
client: rename rootfs to snapshot in "With" functions
Clarify terminology around functions which use and create
snapshots for containers.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-07-25 15:24:06 -07: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
Stephen J Day
863784f991
snapshot: replace "readonly" with View snapshot type
What started out as a simple PR to remove the "Readonly" column became an
adventure to add a proper type for a "View" snapshot. The short story here is
that we now get the following output:

```
$ sudo ctr snapshot ls
ID 									 PARENT 								 KIND
sha256:08c2295a7fa5c220b0f60c994362d290429ad92f6e0235509db91582809442f3 								  	 Committed
testing4								 sha256:08c2295a7fa5c220b0f60c994362d290429ad92f6e0235509db91582809442f3 Active
```

In pursuing this output, it was found that the idea of having "readonly" as an
attribute on all snapshots was redundant. For committed, they are always
readonly, as they are not accessible without an active snapshot. For active
snapshots that were views, we'd have to check the type before interpreting
"readonly". With this PR, this is baked fully into the kind of snapshot. When
`Snapshotter.View` is  called, the kind of snapshot is `KindView`, and the
storage system reflects this end to end.

Unfortunately, this will break existing users. There is no migration, so they
will have to wipe `/var/lib/containerd` and recreate everything. However, this
is deemed worthwhile at this point, as we won't have to judge validity of the
"Readonly" field when new snapshot types are added.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-07-24 16:58:01 -07:00
Derek McGowan
1491293260
Update dependencies for logrus rename
Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-07-21 16:14:03 -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
Stephen Day
dd7642fc1c Merge pull request #1196 from mlaventure/update-windows-runtime
Update windows runtime
2017-07-21 15:12:53 -07:00
Kenfe-Mickael Laventure
8e12d1fcad
ctr: Allow deleting a container in the Created state
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2017-07-21 18:19:51 +02:00
Kenfe-Mickael Laventure
4bb9ac2828
Sort ctr commands alphabetically
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2017-07-21 18:19:51 +02:00
Kenfe-Mickael Laventure
d0166c42ce
Register content command with ctr
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2017-07-21 18:19:51 +02:00
Kenfe-Mickael Laventure
a4aaa09ccc
Update ctr so it works again on windows
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2017-07-21 18:19:48 +02:00
Sunny Gogoi
912ddbae0f cmd/ctr: add commit command to snapshot
Signed-off-by: Sunny Gogoi <me@darkowlzz.space>
2017-07-20 04:17:15 +05:30
Sunny Gogoi
4dc02c09e7 cmd/ctr: add mount subcmd to snapshot & a flag in prepare
This changeset:
- adds `mount` subcommand to `ctr snapshot`
- adds `snapshot-name` flag for specifying target snapshot name in both `mount`
and `prepare` snapshot subcommands

Signed-off-by: Sunny Gogoi <me@darkowlzz.space>
2017-07-19 14:47:35 +05:30
Stephen Day
8d19513267 Merge pull request #1195 from darkowlzz/tree
cmd/ctr: add tree subcommand in snapshot
2017-07-18 18:14:07 -07:00
rajasec
728f8accc6 Fixing return error on run command
Signed-off-by: rajasec <rajasec79@gmail.com>

Updating the usage and errors for ctr run command

Signed-off-by: rajasec <rajasec79@gmail.com>

Updating the usage of run command

Signed-off-by: rajasec <rajasec79@gmail.com>

Reverting back the imports

Signed-off-by: rajasec <rajasec79@gmail.com>
2017-07-19 21:31:27 +05:30
Sunny Gogoi
659e3d789c cmd/ctr: add tree subcommand in snapshot
Signed-off-by: Sunny Gogoi <me@darkowlzz.space>
2017-07-18 09:38:40 +05:30
Stephen J Day
778b1f1c0c
cmd/ctr: container list should not look up image
Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-07-17 14:51:36 -07:00
Akihiro Suda
a0664b5ce5 comment: dist -> ctr
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2017-07-16 14:45:56 +00:00
Stephen J Day
98f6deb50e cmd/dist: completely remove dist command
Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-07-14 15:48:39 -07:00
Stephen J Day
1db80ed966
cmd/{ctr, dist}: move content command to ctr
Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-07-14 15:31:36 -07:00
Stephen J Day
f7306d7f6c
cmd/{ctr,dist}: move images command to ctr
Rather than make a large PR, we can move parts of the dist commands over
piece by piece. This first step moves over the images command. Others
will follow.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-07-14 14:50:02 -07:00
Stephen J Day
a8b2254911
cmd/{ctr,dist}: label can be a verb
Rather than using the more verbose `set-labels` command, we are changing
the command to set labels for various objects to `label`, as it can be
used as a verb. This matches changes in the content store labeling.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-07-13 14:36:13 -07:00
Stephen J Day
b385798695
containerd: remove GRPC service export
Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-07-12 16:57: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
Derek McGowan
1a49f5ea79 Merge pull request #1167 from crosbymichael/multi-ss
support using multiple snapshotters simultaneously
2017-07-12 13:34:31 -07:00
Akihiro Suda
b06aab713a support using multiple snapshotters simultaneously
e.g. dist pull --snapshotter btrfs ...; ctr run --snapshotter btrfs ...
(empty string defaults for overlayfs)

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-07-12 11:16:12 -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
Michael Crosby
4e8943f7bb Update runtime-spec rc6
This should be the same commit tagged as the 1.0 release

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-07-12 09:32:41 -07:00
Sunny Gogoi
2c1b54f573 cmd/ctr: add prepare subcommand to snapshot
This changeset adds `prepare` subcommand to `ctr snapshot` and removes
`prepare` from `dist rootfs` to keep the basic snapshot operation commands
together.

Signed-off-by: Sunny Gogoi <me@darkowlzz.space>
2017-07-11 21:30:40 +05:30
Sunny Gogoi
99461053f3 cmd/ctr: info marshal Container proto struct
Marshaling Container interface resulted in empty json. Use Container proto
struct to get proper container attributes.

Signed-off-by: Sunny Gogoi <me@darkowlzz.space>
2017-07-09 18:20:21 +05:30
Michael Crosby
f93bfb6233 Add Exec IDs
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-07-06 15:23:08 -07:00
Michael Crosby
448dc0dfa8 Replace events/convert with typeurl
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-07-05 16:05:49 -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
Stephen J Day
396d89e423
cmd/ctr, service/containers: implement container filter
Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-06-30 11:49:16 -07: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
82d0208aaa Implement options for runtime specific settings
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-06-29 15:32:45 -07:00
Stephen J Day
a4fadc596b
errdefs: centralize error handling
Now that we have most of the services required for use with containerd,
it was found that common patterns were used throughout services. By
defining a central `errdefs` package, we ensure that services will map
errors to and from grpc consistently and cleanly. One can decorate an
error with as much context as necessary, using `pkg/errors` and still
have the error mapped correctly via grpc.

We make a few sacrifices. At this point, the common errors we use across
the repository all map directly to grpc error codes. While this seems
positively crazy, it actually works out quite well. The error conditions
that were specific weren't super necessary and the ones that were
necessary now simply have better context information. We lose the
ability to add new codes, but this constraint may not be a bad thing.

Effectively, as long as one uses the errors defined in `errdefs`, the
error class will be mapped correctly across the grpc boundary and
everything will be good. If you don't use those definitions, the error
maps to "unknown" and the error message is preserved.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-06-29 15:00:47 -07:00
Michael Crosby
cfcea71ab0 Update windows and darwin for spec changes
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-06-27 13:20:55 -07:00
Michael Crosby
49f9dc494f Update runc and runtime-spec dependencies
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-06-27 11:44:38 -07:00
Derek McGowan
7f9910d04e
Fix ctr delete to remove snapshot
Fix the behavior of removing snapshot on container delete.
Adds a flag to keep the snapshot if desired.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-06-26 13:38:08 -07:00
Kunal Kushwaha
16b10bb55d Runtime name printed correctly.
Runtime is not printed while container listing due to typo introduced
in #935.
This fixes the Typo.

Signed-off-by: Kunal Kushwaha <kushwaha_kunal_v7@lab.ntt.co.jp>
2017-06-26 11:46:32 +09:00
Kenfe-Mickael Laventure
de632b1084
ctr: add remove subcommand to snapshot
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2017-06-23 18:24:46 -07:00
Kenfe-Mickael Laventure
5a02ae929c
ctr: Properly delete snapshot if run is called with --rm
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2017-06-23 18:01:01 -07:00
Kenfe-Mickael Laventure
95afeb7831
containerd-shim: Use abstract namespace for the unix socket
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2017-06-23 17:48:08 -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
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
8d9ccd646b Merge pull request #935 from kunalkushwaha/ctr-fix-914
Container list and Task List printed separately.
2017-06-23 13:16:07 -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
Kenfe-Mickaël Laventure
2fdb8020c4 Merge pull request #1062 from stevvooe/versioned-services
*: version protobuf service packages
2017-06-22 07:38:09 -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
Phil Estes
76697ac8cb Merge pull request #1060 from samuelkarp/namespace-from-env
namespaces: Export env var and default value
2017-06-21 20:49:33 -04:00
Samuel Karp
9190f98e9c namespaces: Export env var and default value
Signed-off-by: Samuel Karp <skarp@amazon.com>
2017-06-21 17:38:07 -07:00
Michael Crosby
e588b30637 Merge pull request #1058 from dmcgowan/snapshot-command
Update snapshot command in ctr
2017-06-21 17:31:02 -07:00
Derek McGowan
a3d5a818f6
Update snapshot command in ctr
Move existing snapshot command to archive subcommand of snapshot.
Add list command for listing snapshots.
Add usage command for showing snapshot disk usage.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-06-21 17:18:52 -07:00
Michael Crosby
235869eb1f Rename execution service to tasks
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-06-21 14:39:25 -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
Evan Hazlett
0b06fa8518 use event service for task wait
Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-06-21 13:34:24 -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
Kunal Kushwaha
a0f73ae229 Container list and Task List printed separately.
Fix for #914

Signed-off-by: Kunal Kushwaha <kushwaha_kunal_v7@lab.ntt.co.jp>
2017-06-21 10:26:49 +09:00
Michael Crosby
58367550e2 Merge pull request #1036 from crosbymichael/client-addr
Add DefaultAddress to client
2017-06-20 13:39:48 -07:00
Michael Crosby
9efe341f8e Add DefaultAddress to client
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-06-20 13:34:37 -07:00
Evan Hazlett
ab4181649b events: be nice to Sprintf
Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
2017-06-20 16:17:22 -04: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
Stephen J Day
5d13f8027c
cmd/{dist, ctr}: cleanup flushing and alignment
Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-06-16 14:49:48 -07:00
Yanqiang Miao
b88b53212f Add 'ArgsUsage' for some ctr sub-cmds
Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>
2017-06-15 16:04:11 +08: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
Ian Campbell
e9559c6eed ctr: Remove getTempDir
It is unused since 4c1af8fdd8 ("Port ctr to use client") and leaving it
around will just tempt people into writing code with security holes.

Signed-off-by: Ian Campbell <ian.campbell@docker.com>
2017-06-14 15:30:11 +01:00
Stephen J Day
27af417668
containerd: allow containers without an image
Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-06-13 11:23:53 -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
5d1669bcfb Add ctr attach for reattaching to running task
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-06-09 10:10:39 -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
35d74aa9d8 Merge pull request #803 from yuexiao-wang/fix-background
optimize for shim
2017-06-01 15:12:04 -07:00
yuexiao-wang
41308ffa57 optimize for shimCreateCommand
Signed-off-by: yuexiao-wang <wang.yuexiao@zte.com.cn>
2017-05-31 13:57:36 +08:00
Kenfe-Mickaël Laventure
0e56c47f8c Merge pull request #928 from AkihiroSuda/oci-rc6
vendor: OCI Image Spec v1.0.0-rc6
2017-05-30 10:09:28 -07:00
Michael Crosby
f55f40eeec Merge pull request #927 from miaoyq/fix-description-for-pprof
Fix the description of cmd 'pprof threadcreate'
2017-05-30 09:13:57 -07:00
Akihiro Suda
967a4e0e5a ctr shim exec: fix cli flag
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2017-05-27 14:54:38 +00:00