Commit Graph

93 Commits

Author SHA1 Message Date
Mikko Ylinen
e2269f2ae0 archive: skip chmod IsNotExist error
handleLChmod() does not properly check that files behind the handlinks exist
before calling os.Chmod(). We've seen base images where this results in
"no such file or directory" error from os.Chmod() when unpacking the image.

To keep the existing logic but fix the problem, this commit simply skips
IsNotExist error.

Signed-off-by: Mikko Ylinen <mikko.ylinen@intel.com>
2020-03-23 20:58:28 +02:00
Shengjing Zhu
465c11dc87 Fix build with gccgo
+ archive: don't convert syscall.Timespec to unix.Timespec
  archive/tar_unix.go:179:76: error: invalid type conversion (cannot use type syscall.Timespec as type unix.Timespec)
    179 |  timespec := []unix.Timespec{unix.Timespec(fs.StatAtime(st)), unix.Timespec(fs.StatMtime(st))}
+ gccgo has no plugin support
  https://github.com/golang/go/issues/36403
+ update github.com/containerd/continuity
  to include same fix for Timespec

Signed-off-by: Shengjing Zhu <zhsj@debian.org>
2020-01-07 19:28:26 +08:00
Tonis Tiigi
372472b5f6 archive: truncate modification time
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2019-08-27 17:42:32 -07:00
Derek McGowan
bcc4a146e4
Support applying with parent directories
Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2019-08-16 15:49:47 -07:00
Lantao Liu
81386df917
Add direct unpack support for overlay and aufs
Signed-off-by: Lantao Liu <lantaol@google.com>
2019-08-15 12:09:32 -07:00
dzzg
612628c2f9 fix wrong spells in compression.go
Signed-off-by: zhengguang zhu <zhengguang.zhu@daocloud.io>
2019-07-29 12:47:17 +00:00
Wei Fu
9da7d30362 archive: return chtimes error with path information
Signed-off-by: Wei Fu <fuweid89@gmail.com>
2019-07-25 16:33:19 +08:00
Lantao Liu
14f7e52725 Unpack should set 0755 when the parent directory doesn't exist.
Signed-off-by: Lantao Liu <lantaol@google.com>
2019-02-14 13:38:12 -08:00
Justin Cormack
7db5697719
unix.UtimesNanoAt now supported on Darwin
unix.UtimesNanoAt now supported on Darwin and sets nanosecond precision if the filesystems does.
This call is now generally supported. Note that os.Chtimes also sets nanosecond precision,
but will always follow symlinks so not appropriate.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2019-01-23 17:57:09 +00:00
Wei Fu
132ee9b826 fix: linter issue
megacheck, gosimple and unused has been deprecated and subsumed by
staticcheck. And staticcheck also has been upgraded. we need to update
code for the linter issue.

close: #2945

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2019-01-23 22:54:51 +08:00
Derek McGowan
e6879c498b
Merge pull request #2882 from JoeWrightss/patch-1
Fix annotation typo error
2018-12-14 11:25:04 -08:00
JoeWrightss
903abf33cf Fix annotation typo error
Signed-off-by: JoeWrightss <zhoulin.xie@daocloud.io>
2018-12-14 23:18:42 +08:00
Ace-Tang
6f944e4190 fix: SCHILY.xattrs should be SCHILY.xattr
from golang code
bad6b6fa91/src/archive/tar/common.go (L110)

add unit test for tar xattr

Fixes: #2863

Signed-off-by: Ace-Tang <aceapril@126.com>
2018-12-13 09:56:26 +08:00
zhangyue
996c60616a fix: fix error info start capitalized
Signed-off-by: zhangyue <zy675793960@yeah.net>
2018-11-28 15:26:16 +08:00
Ivan Markin
a20603090f archive: add support for OpenBSD
Signed-off-by: Ivan Markin <sw@nogoegst.net>
2018-10-12 22:29:24 +00:00
Phil Estes
90b7b88e10
Merge pull request #2696 from dmcgowan/import-docker-tar-test
Content store fix and import integration test
2018-10-03 09:57:25 +02:00
Derek McGowan
b6107dca86
Add import integration test
Move tar creation test utilities to separate package
Test all supported formats for import

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2018-10-01 11:47:10 -07:00
Derek McGowan
db358a9fd2
Fix panic when bufio Reader called in 2 goroutines
A panic was seen related to the buffer being reset in
one goroutine while being read in another. In the case
of pigz an early cancellation will cause the reader to
close, resetting the buffer and signaling the process
to shut down, but races since the process must stop
reading before the reset otherwise the a panic may occur.
This fix guarantees that the bufio is always reset and
returned to the pool on the same goroutine that is
doing the read. If a buffer is not fully read the
buffered reader should just be discarded and not
returned back to the pool.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2018-09-26 18:11:30 -07:00
Maksym Pavlenko
e8fac24e7b
Remove decompression benchmark, use sync.Once for initialization
Benchmark gist: https://git.io/fASMy

Signed-off-by: Maksym Pavlenko <makpav@amazon.com>
2018-09-18 17:09:12 -07:00
Maksym Pavlenko
003b27eff4
Move compression benchmark test data to gist
Signed-off-by: Maksym Pavlenko <makpav@amazon.com>
2018-09-17 13:41:04 -07:00
Maksym Pavlenko
4d7d63f390
Improve layer decompression speed by using pigz
Signed-off-by: Maksym Pavlenko <makpav@amazon.com>
2018-09-17 13:41:04 -07:00
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