Commit Graph

189 Commits

Author SHA1 Message Date
Michael Crosby
653f2f1ce4
Merge pull request #6291 from ningmingxiao/dev1
fix when kernel version < 4.13rc1 by using index=off cause test error
2021-12-20 14:24:54 -05:00
Maksym Pavlenko
fd07b03689
Merge pull request #6122 from alakesh/ext4_lazy 2021-12-18 11:13:59 -08:00
haoyun
c0d07094be feat: Errorf usage
Signed-off-by: haoyun <yun.hao@daocloud.io>
2021-12-13 14:31:53 +08:00
Alakesh Haloi
dc13bcd51e Enable lazy init for ext4 with devicemapper
Add file system options for config file, so that user can use
non-default file system parameters for the fs type of choice
Using file system options in config file overwrites the default
options already being used.

Signed-off-by: Alakesh Haloi <alakeshh@amazon.com>
2021-12-07 13:32:32 -08:00
ningmingxiao
6ff1a59345
fix when kernel version < 4.13rc1 by using index=off cause overlay test error
Signed-off-by: ningmingxiao <ning.mingxiao@zte.com.cn>
2021-12-01 21:48:52 +08:00
Daniel Canter
c18c2e7356 Fix spelling mistake in Windows snapshotter
deactvateErr -> deactivateErr

Signed-off-by: Daniel Canter <dcanter@microsoft.com>
2021-10-18 08:54:55 -07:00
haoyun
ac2df3ba9a test: check file content after mount
Signed-off-by: haoyun <yun.hao@daocloud.io>
2021-10-09 18:19:34 +08:00
zounengren
3a713811be run gofmt with Go 1.17
Signed-off-by: Zou Nengren <zouyee1989@gmail.com>
2021-10-07 20:16:59 +08:00
Derek McGowan
3f00006f72
Merge pull request from GHSA-c2h3-6mxw-7mvq
v1 & v2 runtimes: reduce permissions for bundle dir
2021-10-04 08:24:47 -07:00
Derek McGowan
7c621e1fcc
btrfs: reduce permissions on plugin directories
Disallow traversal into directories that may contain
unpacked or mounted image filesystems.

Signed-off-by: Derek McGowan <derek@mcg.dev>
Signed-off-by: Samuel Karp <skarp@amazon.com>
2021-09-24 11:57:58 -07:00
Eng Zer Jun
50da673592
refactor: move from io/ioutil to io and os package
The io/ioutil package has been deprecated as of Go 1.16, see
https://golang.org/doc/go1.16#ioutil. This commit replaces the existing
io/ioutil functions with their new definitions in io and os packages.

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2021-09-21 09:50:38 +08:00
Alakesh Haloi
91b64c58b1 add xfs support to devicemapper snapshotter
ext4 file system was supported before. This adds support for xfs as
well. Containerd config file can have fs_type as an additional option
with possible values as "xfs" and "ext4" for now. In future other
fstype support can be added. A snapshot created from a committed
snapshot inherits the file system type of the parent. Any new snapshots
that has no parent is created with the file system type indicated in
config. If there is no config for file system type is found, then
ext4 is assumed. This allows users to use xfs as an optional file system
type.

Signed-off-by: Alakesh Haloi <alakeshh@amazon.com>
2021-09-11 21:43:27 -07:00
Sebastiaan van Stijn
2ac9968401
replace uses of os/exec with golang.org/x/sys/execabs
Go 1.15.7 contained a security fix for CVE-2021-3115, which allowed arbitrary
code to be executed at build time when using cgo on Windows. This issue also
affects Unix users who have “.” listed explicitly in their PATH and are running
“go get” outside of a module or with module mode disabled.

This issue is not limited to the go command itself, and can also affect binaries
that use `os.Command`, `os.LookPath`, etc.

From the related blogpost (ttps://blog.golang.org/path-security):

> Are your own programs affected?
>
> If you use exec.LookPath or exec.Command in your own programs, you only need to
> be concerned if you (or your users) run your program in a directory with untrusted
> contents. If so, then a subprocess could be started using an executable from dot
> instead of from a system directory. (Again, using an executable from dot happens
> always on Windows and only with uncommon PATH settings on Unix.)
>
> If you are concerned, then we’ve published the more restricted variant of os/exec
> as golang.org/x/sys/execabs. You can use it in your program by simply replacing

This patch replaces all uses of `os/exec` with `golang.org/x/sys/execabs`. While
some uses of `os/exec` should not be problematic (e.g. part of tests), it is
probably good to be consistent, in case code gets moved around.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-08-25 18:11:09 +02:00
Akihiro Suda
d3aa7ee9f0
Run go fmt with Go 1.17
The new `go fmt` adds `//go:build` lines (https://golang.org/doc/go1.17#tools).

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2021-08-22 09:31:50 +09:00
Kazuyoshi Kato
4dd5ca70fb script: update golangci-lint from v1.38.0 and v1.36.0 to v1.42.0
golint has been deprecated and replaced by revive since v1.41.0.

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
2021-08-19 16:27:16 -07:00
Derek McGowan
6f027e38a8
Remove redundant build tags
Remove build tags which are already implied by the name of the file.
Ensures build tags are used consistently

Signed-off-by: Derek McGowan <derek@mcg.dev>
2021-08-05 22:27:46 -07:00
Fu Wei
5280530a0d
Merge pull request #5624 from ktock/overlayupper 2021-07-28 13:20:23 +08:00
ktock
67406b3732 overlay: add an optional label of upperdir location of each snapshot
Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
2021-07-28 09:52:51 +09:00
Kern Walster
f1d79d33b8 Discard blocks when removing a thin device
dmsetup does not discard blocks when removing a thin device. The unused blocks
are reused by the thin-pool, but will remain allocated in the underlying
device indefinitely. For loop device backed thin-pools, this results in
"lost" disk space in the underlying file system as the blocks remain allocated
in the loop device's backing file.

This change adds an option, discard_blocks, to the devmapper snapshotter which
causes the snapshotter to issue blkdiscard ioctls on the thin device before
removal. With this option enabled, loop device setups will see disk space
return to the underlying filesystem immediately on exiting a container.

Fixes #5691

Signed-off-by: Kern Walster <walster@amazon.com>
2021-07-21 16:06:29 +00:00
Kazuyoshi Kato
03ee450060 snapshot/devmapper: log exported methods correctly
- View was somehow logging itself as "prepare"
- Cleanup should have its debug log as like other exported methods

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
2021-06-24 16:16:50 -07:00
Michael Crosby
bd4fcf6322
Merge pull request #5422 from TBBle/use-layer-deactivate-instead-of-vhd-detach
Use DeactivateLayer to unlock layers that we cannot rename
2021-06-03 11:14:11 -04:00
Alakesh Haloi
b996e49c5c Do not run btrfs tests if btrfs kernel module is not loaded
Signed-off-by: Alakesh Haloi <alakeshh@amazon.com>
2021-05-26 13:45:56 -07:00
Paul "TBBle" Hampson
402acd7c1e Small typo fix "reimporst"
Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
2021-04-27 01:31:32 +10:00
Paul "TBBle" Hampson
f216270595 Use DeactivateLayer to recover layers that we cannot rename
It seems that something has shifted in an API, and vhd.DetachVhd is
returning "failed to open virtual disk: invalid argument" on Windows
Server LTSC 2019.

Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
2021-04-27 01:31:31 +10:00
Paul "TBBle" Hampson
8a4cbabc64 Reimport windows layers when comitting snapshots
A Scratch layer only contains a sandbox.vhdx, but to be used as a parent
layer, it must also contain the files on-disk.

Hence, we Export the layer from the sandbox.vhdx and Import it back into
itself, so that both data formats are present.

Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
2021-04-14 20:45:59 +10:00
Alakesh Haloi
5ce35ac398 devmapper: log pool status when mkfs fails
If mkfs on device mapper thin pool fails, it will show pool status
as returned by dmsetup for enahnced error reporting.

Signed-off-by: Alakesh Haloi <alakeshh@amazon.com>
2021-04-12 19:24:04 +00:00
Derek McGowan
261c107ffc
Merge pull request #5278 from mxpv/toml
Migrate TOML to github.com/pelletier/go-toml
2021-04-01 21:24:52 -07:00
Kazuyoshi Kato
e1f51ba73d Use os.File#Seek() to get the size of a block device
Instead of calling blockdev(1), this change uses os.File#Seek which
would be more effecient.

https://github.com/firecracker-microvm/firecracker/pull/1371

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
2021-03-26 10:14:38 -07:00
Maksym Pavlenko
ddd4298a10 Migrate current TOML code to github.com/pelletier/go-toml
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2021-03-25 13:13:33 -07:00
Sebastiaan van Stijn
708299ca40
Move RunningInUserNS() to its own package
This allows using the utility without bringing whole of "sys" with it.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-03-23 11:29:53 +01:00
Kazuyoshi Kato
7704fe72d0 Specifically mention "mkfs.ext4" on the error from the command
Before the change, the error on the caller-side (e.g. ctr) was
something like

> unpack: failed to prepare extraction snapshot "...": exit status 5:
> unknown

which was too cryptic.

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
2021-03-19 10:38:47 -07:00
Sebastiaan van Stijn
ba8f9845ec
move overlay-checks to an overlayutils package
This allows using the utilities without importing the whole
snapshotter.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-03-15 19:18:50 +01:00
Derek McGowan
35eeb24a17
Fix exported comments enforcer in CI
Add comments where missing and fix incorrect comments

Signed-off-by: Derek McGowan <derek@mcg.dev>
2021-03-12 08:47:05 -08:00
Derek McGowan
ddf6594fbe
Merge pull request #5076 from AkihiroSuda/ovl-k511
overlay: support "userxattr" option (kernel 5.11)
2021-03-09 07:07:30 -08:00
Michael Crosby
7738246cd9
Merge pull request #5111 from ctrlaltdel121/master
mark device faulty after parent fails to suspend
2021-03-08 14:13:25 -05:00
Maksym Pavlenko
e1b4c0ad43 Remove flaky devmapper check
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2021-03-03 14:51:11 -08:00
Jeremy Williams
51a72f0492 mark device faulty after parent fails to suspend
When an error is returned here, unlike the other error returns in the function, nothing is done to mark the added device as faulty or remove it.
I have observed this causing future snapshot creations to continue to attempt to use the same ID (from the sequence) to create new devices
and get blocked because the device already exists because it was not rolled back here.

Hopefully fixes #5110

Signed-off-by: Jeremy Williams <ctrlaltdel121@gmail.com>
2021-03-03 17:02:07 -05:00
Akihiro Suda
9ade247b38
overlay: support "userxattr" option (kernel 5.11)
The "userxattr" option is needed for mounting overlayfs inside a user namespace with kernel >= 5.11.

The "userxattr" option is NOT needed for the initial user namespace (aka "the host").

Also, Ubuntu (since circa 2015) and Debian (since 10) with kernel < 5.11 can mount the overlayfs in a user namespace without the "userxattr" option.

The corresponding kernel commit: 2d2f2d7322ff43e0fe92bf8cccdc0b09449bf2e1
> ovl: user xattr
>
> Optionally allow using "user.overlay." namespace instead of "trusted.overlay."
> ...
> Disable redirect_dir and metacopy options, because these would allow privilege escalation through direct manipulation of the
> "user.overlay.redirect" or "user.overlay.metacopy" xattrs.

Fix issue 5060

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2021-03-01 13:54:51 +09:00
Justin
0cc3991387
Merge pull request #4912 from dcantah/dcantah/wcow-sandbox-size
Scratch size customization and UVM scratch creation for WCOW snapshotter
2021-02-17 15:19:19 -08:00
Kazuyoshi Kato
2ac33d79fe test: fix assert.Check's argumets to show its parameters correctly
The change I made at db6075fc2 didn't show its parameters correctly.

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
2021-02-04 10:56:58 -08:00
Kazuyoshi Kato
db6075fc24 snapshot/devmapper: log actual values to investigate #4965
This test has been flaky in GitHub Actions. This change logs the
values from devmapper to further investigate the issue.

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
2021-02-01 16:27:59 -08:00
Shengjing Zhu
074873c68e Add cgo tag to btrfs plugin
btrfs plugin needs CGO support. However on riscv64, cgo
is only support on go1.16 (not released yet).
Instead of setting no_btrfs manually, adding a cgo tag tells
the compiler to skip it automatically.

Signed-off-by: Shengjing Zhu <zhsj@debian.org>
2021-01-23 02:42:57 +08:00
Derek McGowan
9b9de47eb9
Merge pull request #4824 from dcantah/dcantah/reuse-scratch
Add scratch space re-use functionality to LCOW snapshotter
2021-01-21 17:21:31 -08:00
Daniel Canter
ff1451cab8 Scratch size customization and UVM scratch creation for WCOW snapshotter
* Currently we rely on making the UVMs sandbox.vhdx in the shim itself instead of this being
made by the snapshotter itself. This change adds a label that affects whether to create the UVMs
scratch layer in the snapshotter itself.

* Adds container scratch size customization. Before adding the computestorage calls
(vendored in with https://github.com/containerd/containerd/pull/4859) there was no way to make a containers
or UVMs scratch size less than the default (20 for containers and 10 for the UVM).

Signed-off-by: Daniel Canter <dcanter@microsoft.com>
2021-01-18 07:33:52 -08:00
Daniel Canter
3e5acb9d91 Add scratch space re-use functionality to LCOW snapshotter
Currently we would create a new disk and mount this into the LCOW UVM for every container but there
are certain scenarios where we'd rather just mount a single disk and then have every container share this one
storage space instead of every container having it's own xGB of space to play around with.

This is accomplished by just making a symlink to the disk that we'd like to share and then
using ref counting later on down the stack in hcsshim if we see that we've already mounted this
disk.

Signed-off-by: Daniel Canter <dcanter@microsoft.com>
2021-01-13 15:20:46 -08:00
Maksym Pavlenko
04df60d106
Merge pull request #4858 from samuelkarp/freebsd-native-snapshotter
Support the native snapshotter on FreeBSD
2021-01-11 09:52:56 -08:00
Peng Tao
b7026236f4 snapshot/devmapper: use losetup in mount package
No need to use the private losetup command line wrapper package.
The generic package provides the same functionality.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2021-01-04 10:15:04 -08:00
Samuel Karp
b624486c84
native: support for FreeBSD
Signed-off-by: Samuel Karp <me@samuelkarp.com>
2020-12-22 21:26:04 -08:00
Shengjing Zhu
5988bfc1ef docs: Various typo found by codespell
Signed-off-by: Shengjing Zhu <zhsj@debian.org>
2020-12-22 13:22:16 +08:00
Maksym Pavlenko
a5f9613b83
Merge pull request #3927 from katiewasnothere/snapshotter_check
add check that snapshotter supports the image platform when unpacking
2020-12-16 14:25:08 -08:00