Commit Graph

225 Commits

Author SHA1 Message Date
Samuel Karp
59f210d8ba
Merge pull request #7700 from jellor/remove-rollback 2022-11-20 23:13:49 -08:00
guodong
bf777a70b1 remove duplicated tx rollback
Signed-off-by: guodong <guodong9211@gmail.com>
2022-11-19 13:57:55 +08:00
Maksym Pavlenko
a30e1bb081
Merge pull request #7696 from dcantah/unused-arg
overlay: Remove unused method param
2022-11-18 10:56:16 -08:00
Danny Canter
e4130b2a02 overlay: Remove unused method param
`getCleanupDirectories` didn't use the storage transactor.

Signed-off-by: Danny Canter <danny@dcantah.dev>
2022-11-18 03:04:32 -08:00
guodong
c245347e96 tx rollback when GetInfo return error
Signed-off-by: guodong <guodong9211@gmail.com>
2022-11-16 23:04:26 +08:00
Danny Canter
4b2a23e7ea overlayutils: Add fastpath for userxattr check
Cleaning up TODO's. If we're on >= 5.11 we need userxattr so check
the kernel version to skip the manual check via mounting. It feels
odd to use contrib/seccomp here but the alternative is pulling that
kernel parsing code out into the main pkgs. Another is using the moby
parser but that's in moby/moby which is also a dep we don't want here..

Signed-off-by: Danny Canter <danny@dcantah.dev>
2022-10-31 17:19:23 -07:00
xin.li
396b6d670f fix missing close
Signed-off-by: xin.li <xin.li@daocloud.io>
2022-09-24 20:54:21 +08:00
Anastassios Nanos
adfbda464b Add ext2 fs support to devmapper snapshotter
Signed-off-by: Anastassios Nanos <ananos@nubificus.co.uk>
2022-09-19 09:21:26 +00:00
Maksym Pavlenko
ca3b9b50fe Run gofmt 1.19
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-08-04 18:18:33 -07:00
Derek McGowan
b848924ae8
Merge pull request #7195 from falser101/feature/cleanup
test: error strings should not be capitalized
2022-07-27 15:19:34 -07:00
jianfei.zhang
276a6f133a test: error strings should not be capitalized
Signed-off-by: jianfei.zhang <jianfei.zhang@daocloud.io>
2022-07-26 09:56:20 +08:00
Jeff Widman
050cd58ce6 Drop deprecated ioutil
`ioutil` has been deprecated by golang. All the code in `ioutil` just
forwards functionality to code in either the `io` or `os` packages.

See https://github.com/golang/go/pull/51961 for more info.

Signed-off-by: Jeff Widman <jeff@jeffwidman.com>
2022-07-23 08:36:20 -07:00
Fu Wei
a5d7185c72
Merge pull request #7008 from mmmmmmmxl/fix/userattr-unmount 2022-06-11 06:59:42 +08:00
Kazuyoshi Kato
4ec6a379c0
Merge pull request #6918 from dcantah/windows-snapshotter-cleanup
Windows snapshotter touch ups and new functionality
2022-06-10 11:08:18 -07:00
Swagat Bora
61690d76d2 Improve naming consistencies in comments in snapshotter.go
Signed-off-by: Swagat Bora <sbora@amazon.com>
2022-06-09 17:16:37 +00:00
Xinlin Ma
fa4720fa16 fix add ro mount for userattr-unmount unexpected timeout
Signed-off-by: Xinlin Ma <forblue.lin@gmail.com>
2022-06-08 11:34:05 +08:00
Swagat Bora
92d360b58a fix minor spelling mistake: lablel -> label
Signed-off-by: Swagat Bora <sbora@amazon.com>
2022-06-07 21:05:47 +00:00
Daniel Canter
44e12dc5d8 Windows snapshotter touch ups and new functionality
This change does a couple things to remove some cruft/unused functionality
in the Windows snapshotter, as well as add a way to specify the rootfs
size in bytes for a Windows container via a new field added in the CRI api in
k8s 1.24. Setting the rootfs/scratch volume size was assumed to be working
prior to this but turns out not to be the case.

Previously I'd added a change to pass any annotations in the containerd
snapshot form (containerd.io/snapshot/*) as labels for the containers
rootfs snapshot. This was added as a means for a client to be able to provide
containerd.io/snapshot/io.microsoft.container.storage.rootfs.size-gb as an
annotation and have that be translated to a label and ultimately set the
size for the scratch volume in Windows. However, this actually only worked if
interfacing with the CRI api directly (crictl) as Kubernetes itself will
fail to validate annotations that if split by "/" end up with > 2 parts,
which the snapshot labels will (containerd.io / snapshot / foobarbaz).

With this in mind, passing the annotations and filtering to
containerd.io/snapshot/* is moot, so I've removed this code in favor of
a new `snapshotterOpts()` function that will return platform specific
snapshotter options if ones exist. Now on Windows we can just check if
RootfsSizeInBytes is set on the WindowsContainerResources struct and
then return a snapshotter option that sets the right label.

So all in all this change:
- Gets rid of code to pass CRI annotations as labels down to snapshotters.

- Gets rid of the functionality to create a 1GB sized scratch disk if
the client provided a size < 20GB. This code is not used currently and
has a few logical shortcomings as it won't be able to create the disk
if a container is already running and using the same base layer. WCIFS
(driver that handles the unioning of windows container layers together)
holds open handles to some files that we need to delete to create the
1GB scratch disk is the underlying problem.

- Deprecates the containerd.io/snapshot/io.microsoft.container.storage.rootfs.size-gb
label in favor of a new containerd.io/snapshot/windows/rootfs.sizebytes label.
The previous label/annotation wasn't being used by us, and from a cursory
github search wasn't being used by anyone else either. Now that there is a CRI
field to specify the size, this should just be a field that users can set
on their pod specs and don't need to concern themselves with what it eventually
gets translated to, but non-CRI clients can still use the new label/deprecated
label as usual.

- Add test to cri integration suite to validate expanding the rootfs size.

Signed-off-by: Daniel Canter <dcanter@microsoft.com>
2022-06-06 14:57:07 -07:00
cardy.tang
9f9ebbd991 Fix tx closed error when upperdirlabel specified
When upperdirLabel specified, overlay Update will throw tx closed error since Commit is invoked before GetInfo

Signed-off-by: cardy.tang <zuniorone@gmail.com>
2022-05-24 10:34:43 +08:00
Gavin Inglis
c721c8e274 devmapper docs: small fixes
Signed-off-by: Gavin Inglis <giinglis@amazon.com>
2022-05-06 18:34:06 +00:00
austinvazquez
57d2bce749 docs: minor fixes in snapshots.Snapshotter comments
Signed-off-by: Austin Vazquez <austin.vazquez.dev@gmail.com>
2022-05-02 15:51:11 +00:00
Kazuyoshi Kato
1a095e18ba Rename Size_ to Size
Previouslty "Size" was reserved by protoc-gen-gogoctrd and user-generated
"Size" was automatically renamed to "Size_" to avoid conflicts.

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
2022-04-22 15:31:53 +00:00
Kazuyoshi Kato
237ef0de9b Remove all gogoproto extensions
This commit removes the following gogoproto extensions;

- gogoproto.nullable
- gogoproto.customename
- gogoproto.unmarshaller_all
- gogoproto.stringer_all
- gogoproto.sizer_all
- gogoproto.marshaler_all
- gogoproto.goproto_unregonized_all
- gogoproto.goproto_stringer_all
- gogoproto.goproto_getters_all

None of them are supported by Google's toolchain (see #6564).

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
2022-04-20 07:23:28 +00:00
Kazuyoshi Kato
88c0c7201e Consolidate gogo/protobuf dependencies under our own protobuf package
This would make gogo/protobuf migration easier.

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
2022-04-19 15:53:36 +00:00
Kazuyoshi Kato
80b825ca2c Remove gogoproto.stdtime
This commit removes gogoproto.stdtime, since it is not supported by
Google's official toolchain
(see https://github.com/containerd/containerd/issues/6564).

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
2022-04-19 13:39:30 +00:00
Shinichi Morimoto
942af12032 fix pool_device_test.go
While executing mke2fs, 'Not enough space to build proposed filesystem while setting up superblock' error is happend on Ubuntu20.04

Signed-off-by: Shinichi Morimoto <shnmorimoto@gmail.com>
2022-04-14 09:55:29 +09:00
Akihiro Suda
493baa6e7c
Add docs/snapshots
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2022-04-06 13:31:18 +09:00
Akihiro Suda
195fc74244
docs: migrate config v1 to v2
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2022-04-05 16:41:54 +09:00
Maksym Pavlenko
871b6b6a9f Use testify
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-04-01 18:17:58 -07:00
Tonis Tiigi
fe426227d4 native: fix deadlock from leaving transactions open
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2022-03-23 15:48:42 -07:00
Kazuyoshi Kato
067611fdea Remove enumvalue_customname, goproto_enum_prefix and enum_customname
This commit removes gogoproto.enumvalue_customname,
gogoproto.goproto_enum_prefix and gogoproto.enum_customname.

All of them make proto-generated Go code more idiomatic, but we already
don't use these enums in our external-surfacing types and they are anyway
not supported by Google's official toolchain (see #6564).

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
2022-03-21 19:48:16 +00:00
Eng Zer Jun
52d307ac13
test: remove redundant mountPoint
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-03-16 10:01:47 +08:00
Eng Zer Jun
18ec2761c0
test: use T.TempDir to create temporary test directory
The directory created by `T.TempDir` is automatically removed when the
test and all its subtests complete.

Reference: https://pkg.go.dev/testing#T.TempDir
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-03-15 14:03:50 +08:00
Henry Wang
0d0b2bd4fe Mount devmapper xfs file system with "nouuid" option.
Two xfs file systems with same UUID can not be mounted on the same system.
However devmapper snapshots will have same UUID as original filesystem.

This patch fixes the bug by mounting a xfs file system with "nouuid" option.

Signed-off-by: Henry Wang <henwang@amazon.com>
2022-03-10 00:05:39 +00:00
Henry Wang
2d9d5fddbd Document fs_type and fs_options in snapshots/devmapper/README.md
Resolves: #6499

Signed-off-by: Henry Wang <henwang@amazon.com>
2022-02-02 21:57:44 +00:00
haoyun
bbe46b8c43 feat: replace github.com/pkg/errors to errors
Signed-off-by: haoyun <yun.hao@daocloud.io>
Co-authored-by: zounengren <zouyee1989@gmail.com>
2022-01-07 10:27:03 +08:00
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