Commit Graph

122 Commits

Author SHA1 Message Date
John Howard
2c4b7f6bd1 Fixup archive/tar_windows.go type
Signed-off-by: John Howard <jhoward@microsoft.com>
2018-08-20 12:02:04 -07: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
Phil Estes
c55b9636f7
Merge pull request #2263 from alibaba/fix_no_gzip
fixbug: blob for schemav1 could be uncompressed
2018-07-30 18:49:28 -04:00
Wei Fu
3b1534c47a bugfix: allow hardlink to softlink file
With `fs.RootPath`, the target file will be the file which the softlink
points to, like:

  touch /tmp/zzz
  ln -s /tmp/zzz /tmp/xxx
  ln /tmp/xxx /tmp/yyy

The `/tmp/yyy` should be same with the `/tmp/xxx`, not `/tmp/zzz`. We
should allow hardlink to softlink file.

Signed-off-by: Wei Fu <fhfuwei@163.com>
2018-07-19 15:13:50 +08:00
Derek McGowan
1c6929cbd4
Remove use of crypto rand in tests
Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2018-07-12 17:51:55 -07:00
frank yang
046536cfb1 fixbug: blob for schemav1 could be uncompressed
Signed-off-by: frank yang <yyb196@gmail.com>
2018-06-08 11:50:54 +08:00
Michael Crosby
009ba4d797 Move testutils to pkg
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-05-22 17:08:38 -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
Michael Wan
7fd6d5e2be fix words misspell
Signed-off-by: Michael Wan <zirenwan@gmail.com>
2018-04-23 00:09:42 -04:00
Darren Stahl
84f6fce240 Make hcsshim layerwriter close a fatal error
Signed-off-by: Darren Stahl <darst@microsoft.com>
2018-03-28 18:02:45 -07:00
Derek McGowan
9b111bdc39
Add ignore socket test
Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2018-03-22 13:17:33 -07:00
Ian Campbell
2ec3382d2d Ignore sockets when creating a tar stream of a layer
The go-tar implementation which is used cannot handle sockets.

There's no good reason to preserve a socket, they are basically useless without
the process which made them.

Signed-off-by: Ian Campbell <ian.campbell@docker.com>
2018-03-22 15:19:35 +00:00
Derek McGowan
fd6335f74d
Merge pull request #2163 from AkihiroSuda/userns-mknod
archive: fix logic for skipping mknod when running in userns
2018-03-01 11:37:34 -08:00
Akihiro Suda
fffc111ba8 archive: fix logic for skipping mknod when running in userns
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2018-02-28 03:01:02 +09:00
Stephen J Day
9cdd036393
build: bump to Go 1.10
Bumps the build to use Go 1.10, which allows us to drop the forked tar
package.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2018-02-26 16:47:24 -08: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
Derek McGowan
2a2c8aafba
Add test for consecutive directory removal
Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2018-02-12 10:43:16 -08:00
Brian Goff
c776b6d8d9 Use continuity fs package
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2018-02-07 12:40:52 -05:00
Derek McGowan
d778dd15d8
Fixes missing whiteout parent directories
Ensures include parents is called for whiteouts

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2018-02-02 17:02:14 -08:00
Derek McGowan
dfadd8ce75
Fix duplicate directories entries on metadata change
Currently directory changes are not added to the list of
included directories, allowing those directories to receive
duplicate entries where there is both a metadata change to the
directory and a change to a file under that directory.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2018-01-24 14:28:51 -08: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
Michael Crosby
bbb5b2f15e
Merge pull request #2001 from dmcgowan/fix-whiteout-rootpath
archive: check whiteout path before removal
2018-01-12 15:09:11 -05:00
Derek McGowan
384d46d8bd
archive: check whiteout path before removal
Ensure whiteout is not pointing to the current directory
or parent directory before removing. Protects against invalid
removal of the parent or current directory.

Add whiteout related tar tests using manufactured tar conditions.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2018-01-12 11:43:39 -08:00
Michael Crosby
45fbc3b3c2
Merge pull request #1975 from dnephin/add-unconvert-linter
Add unconvert linter
2018-01-10 10:54:00 -05: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
Derek McGowan
c9dd974c27
Add parent directories to tar
Alternate solution which better accounts for hard links.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2018-01-02 16:01:31 -08:00
Michael Crosby
e479165a38
Merge pull request #1903 from darrenstahlmsft/ArchiveOpts
Implement Archive.apply on Windows
2018-01-02 16:08:36 -05:00
Derek McGowan
d4317a1b0d
Fix parent directories not included in tar
Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-12-15 12:04:47 -08:00
Darren Stahl
c195ebb3e2 Implement archive.Apply on Windows
Signed-off-by: Darren Stahl <darst@microsoft.com>
2017-12-15 11:33:03 -08:00
Michael Crosby
a56e7420a7
Merge pull request #1812 from darrenstahlmsft/revendor
Revendor hcsshim and go-tar
2017-11-29 15:52:07 -05:00
Derek McGowan
bc9cb25012
Update tar to use PAXRecords instead of Xattrs
Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-11-28 17:03:14 -08:00
Derek McGowan
16d00870ef
Add test for prefix header issue
Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-11-28 16:38:26 -08:00
Daniel Nephin
ee04cfa3f9 Add staticcheck linter
Fix issues with sync.Pool being passed an array and not a pointer.
See https://github.com/dominikh/go-tools/blob/master/cmd/staticcheck/docs/checks/SA6002

Add missing tests for content.Copy

Fix T.Fatal being called in a goroutine

Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2017-11-28 13:05:30 -05: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
Stephen Day
70b5668351 Merge pull request #1631 from dmcgowan/cancel-unpack
archive: update apply diff to support context cancellation
2017-10-17 05:33:25 -07:00
Derek McGowan
dcf7ff5db5
Update apply diff to support context cancellation
Allows cancellation of apply when the grpc service issues a cancel.
Adds a timing log for apply.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-10-11 16:48:55 -07:00
Derek McGowan
e20b371807
Remove umask, replace with explicit chmod after create
Call chmod on all open files and created directories to
ensure permission is set as expected without changing umask.

Fixes #1608

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-10-11 15:13:18 -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
f01b139161 archive: use Mkdev, Major and Minor functions from golang.org/x/sys/unix
Now that golang.org/x/sys/unix provides the Mkdev, Major and Minor
functions for every OS, use them instead of the locally defined version
which uses the Linux specific device major/minor encoding.

This also means that the device number should now be properly encoded on
e.g. Darwin, FreeBSD or Solaris.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-10-02 15:13:03 +02:00
Phil Estes
8b938b00bc
Fix FreeBSD compilation
Corrects compile on FreeBSD by handling the lack of ENODATA on FreeBSD.
Since continuity project has already handled this, using their const is
simpler than separating a few extra files in containerd/containerd.

Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com>
2017-09-06 14:38:07 -04: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
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
Kenfe-Mickael Laventure
308ebe7e43
Add missing return when failing to write tar header
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2017-08-04 10:41:38 -07:00
Michael Crosby
c3872b848f Move RootPath to fs package
This moves the RootPath function out of the archive package and into the
fs package for external use.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-07-26 14:26:27 -04:00
Derek McGowan
afec478beb Update tar path resolution
Fixes bug for resolving symlinks which allowed fully resolving
an existing symlink to a path, causing some symlinks to get
overridden as symlinks to self.
Updates logic to split name into parent path, resolve the parent
path, then safely join back with the base name.
Uses the split code to ensure parent directories are created in
all cases.
Replaces `rootJoin` with filepath.Join to the root, which already
correctly cleans relative symlinks to the root.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-07-24 17:51:47 -07:00
Kenfe-Mickael Laventure
eb4e0b5fb1
Add AppVeyor configuration
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2017-07-21 18:19:51 +02:00
Stephen Day
28e8d95a64 Merge pull request #1210 from dmcgowan/use-forked-tar
Use forked archive/tar package for go 1.8 regression
2017-07-19 15:34:55 -07:00
Derek McGowan
23aa4910c0
Use forked archive/tar package
Use fork of archive/tar to carry changes to tar for
all go versions.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-07-18 18:32:44 -07:00
Derek McGowan
60792458a3
Replace uses of filepath.Join in Apply
Replace cases where a tar specified name is joined to a directory
with root path to bound name to path.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-07-18 18:30:21 -07:00
Derek McGowan
4a3f98cb61
Add link breakout checks and tests
Ensure symlinks cannot be used to breakout of unpack directory.
Evaluate absolute symlinks as scoped to unpack directory.
Allow symlinks which point outside the root to be created.
Scope all resolution of symlinks to the unpack directory.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-07-18 12:16:13 -07:00
Tonis Tiigi
19aed1a049 archive: fix allocation leak
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2017-07-12 10:24:52 -07:00
Derek McGowan
3ae69c43d8
Add diff service implementation
Add snapshot subcommand to ctr for creating diffs of RW layers.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-05-16 13:48:53 -07:00
Justin Cormack
699f846813 Further fixes for FreeBSD
This fixes a lot more issues for FreeBSD, including update for continuity vendor.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2017-05-11 10:45:59 +01:00
Michael Crosby
e7e60a8a1f Merge pull request #799 from dmcgowan/snapshot-fs-tests
Add test suite for filesystem tests
2017-05-08 10:19:42 -07:00
Justin Cormack
1d27259777 Partial port to Darwin and FreeBSD
This mainly fixes Linux vs generic Unix differences, with some
differences between Darwin and Freebsd (which are close bit not
identical). Should make fixing for other Unix platforms easier.

Note there are not yet `runc` equivalents for these platforms;
my current use case is image manipulation for the `moby` tool.
However there is interest in OCI runtime ports for both platforms.

Current status is that MacOS can build and run `ctr`, `dist`
and `containerd` and some operations are supported. FreeBSD 11
still needs some more fixes to continuity for extended attributes.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2017-05-04 18:11:53 +01:00
Stephen J Day
b4c6e5f9d3
vendor: move to new continuity import paths
Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-05-03 18:51:41 -07:00
Derek McGowan
c2c490c66c
Add test suite for filesystem tests
Updates tar tests to use test suite
Add hardlink tests

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-05-03 10:46:46 -07:00
Derek McGowan
51b8e468e5
Fix hardlinks with unmodified files
Previously hardlinking to an unmodified file or linking to a file
which was touched by not detected as modified caused a new file
to be created on unpack. This new file and the original source file
were not linked since no link record was created in the tar. This
change addresses this by adding links for all hardlinks to a file
when it is detected as changed. These links will be written after
the source file is written and may occur out of order in regard to
file name.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-04-04 15:00:19 -07:00
Derek McGowan
2b186fd1f6
Update tar test to avoid touching before hardlinking
Touching the file before hardlinking was covering up a bug in
how hard links are handled in tar. Without the touch the hardlink
should still be included and both files should hardlink after
the tar is applied.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-04-04 15:00:12 -07:00
Michael Crosby
4f2b443a27 Rewrite imports for new github org
This rewrites the Go imports after switching to the new github org.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-04-03 14:05:44 -07:00
unclejack
7b4d238ee3 archive,cmd,images: clean up some code
Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com>
2017-03-30 11:41:22 +03:00
unclejack
e91d6805af archive,cmd,fs: return err directly
Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com>
2017-03-30 11:32:13 +03:00
Akihiro Suda
6089c1525b new package: compression (ported from docker/pkg/archive)
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2017-03-16 05:29:27 +00:00
Akihiro Suda
750cdc951f snapshotter: add more assertion
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2017-03-06 08:34:43 +00:00
kevinetc123
fa584958fc using github.com/pkg/errors & correct some typo mistakes
Signed-off-by: kevinetc123 <kaiwentan@harmonycloud.cn>
2017-02-24 10:59:11 +08:00
Aaron.L.Xu
a3cae915c3 fix some typos
Signed-off-by: Aaron.L.Xu <likexu@harmonycloud.cn>
2017-02-21 15:02:36 +08:00
Derek McGowan
3c94bf814e Add deletion test
Test deleting multiple files, directories, and creating
the equivalent of an opaque directory.

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
2017-02-17 13:58:48 -08:00
Derek McGowan
6443891a7d Update log lines to use containerd log package
Removed unused requires root test function and updated
tar requires function to use lookup method.

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
2017-02-17 11:50:49 -08:00
Derek McGowan
0deba01621 Add archive package
Archive package handles generating and applying diff tar streams
based on the OCI diff tar specification.

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
2017-02-17 11:49:58 -08:00