Commit Graph

235 Commits

Author SHA1 Message Date
Wei Fu
6b7e237fc7 chore: use go fix to cleanup old +build buildtag
Signed-off-by: Wei Fu <fuweid89@gmail.com>
2022-12-29 14:25:14 +08:00
Derek McGowan
cfe7ac9956
Merge pull request #7529 from iyear/refactor-metastore-tx
Refactor metastore transaction
2022-12-28 20:08:38 -08:00
iyear
1d0619bc0c Refactor metastore transaction
Signed-off-by: Junyu Liu <ljyngup@gmail.com>
2022-12-28 18:37:28 +08:00
yanggang
b10536d64f
Reused errdefs define error
Signed-off-by: yanggang <gang.yang@daocloud.io>
2022-12-27 14:09:40 +08:00
Derek McGowan
bd61843a25
Merge pull request #7081 from kzys/old-kernel
Enable checkRename test
2022-12-20 13:43:22 -08:00
Derek McGowan
8b3ed9f4ee
Merge pull request #7781 from dcantah/withtransaction
metastore: Add WithTransaction convenience method
2022-12-20 13:42:03 -08:00
Danny Canter
aa8a389c51 overlay snapshotter: Make use of WithTransaction
Move the overlay snapshotter over to using the WithTransaction convenience
method. This simplifies needing to check if we need to rollback a transaction
and saves us from needing to manually Commit ourselves.

Signed-off-by: Danny Canter <danny@dcantah.dev>
2022-12-19 22:49:28 -08:00
Kazuyoshi Kato
d5dd11dcdc Enable checkRename test
One of the cases wouldn't work on overlayfs, but other cases and/or
snapshotters should be tested.

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
2022-12-19 22:06:07 +00:00
mathis-m
2eabcf7026
fix: check for tmpfs when evaluating if userxattr should be used
Signed-off-by: mathis-m <mathis.michel@outlook.de>
2022-12-08 20:55:15 +01:00
Danny Canter
3b71cfd407 metastore: Add WithTransaction convenience method
Most snapshotters end up manually handling the rollback logic, either
by calling `t.Rollback()` in every failure path, setting up a custom
defer func to log on certain errors, or just deferring `t.Rollback()`
even for `snapshotter.Commit()` which *will* cause `t.Rollback()` to return
an error afaict, but it's just never checked and luckily bolt handles this
alright...

The devmapper snapshotter has a solution to this which is to have a
method that starts either a read-only or writable transaction inside
the method, and you pass in a callback to do your bidding and any
failures are rolled back, and if it's writable will handle the commit
for you. This seems like the right model to me, it removes the burden
from the snapshot author to remember to either defer/call rollback
in every method for every failure case.

This change exposes the convenience method from devmapper to the
snapshots/storage package as a method off of `storage.MetaStore` and moves
over the devmapper snapshotter to use this.

Signed-off-by: Danny Canter <danny@dcantah.dev>
2022-12-07 23:49:09 -08:00
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