Commit Graph

13 Commits

Author SHA1 Message Date
Kir Kolyshkin a4d8f720a2 Format sources with gofumpt
gofumpt is a superset of gofmt, enabling some more code formatting
rules.

This commit is brought to you by

	gofumpt -w .

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2023-05-26 16:17:31 -07:00
Nalin Dahyabhai d10c03bc3d Extend driver.ListLayers()
Implement ListLayers() for the aufs, btrfs, and devicemapper drivers,
along with a unit test for them.
Stop filtering out directories with names that aren't 64-hex chars in
vfs and overlay ListLayers() implementations, which is more a convention
than a hard rule.
Have layerStore.Wipe() try to remove remaining listed layers after it
removes the layers that the layerStore knew of.
Close() a dangling ReadCloser in NaiveCreateFromTemplate.
Switch from using plain defer to using t.Cleanup() to handle deleting
layers that tests create, have the addManyLayers() test function do so
as well.
Remove vfs.CopyDir, which near as I can tell isn't referenced anywhere.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2023-04-12 16:05:09 -04:00
Paul Holzinger bb74ff653c
fix inconsitent go build tags
Run `go fmt ./...` which automatically adds the new build tag syntax.
This change is backwards compatible.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-11-02 20:51:27 +01:00
Kir Kolyshkin 68cc6d0219 devmapper: fix unit test
It has been pointed out that sometimes device mapper unit tests
fail with the following diagnostics:

> --- FAIL: TestDevmapperSetup (0.02s)
>    graphtest_unix.go:44: graphdriver: loopback attach failed
>    graphtest_unix.go:48: loopback attach failed

The root cause is the absence of udev inside the container used
for testing, which causes device nodes (/dev/loop*) to not be
created.

The test suite itself already has a workaround, but it only
creates 8 devices (loop0 till loop7). It might very well be
the case that the first few devices are already used by the
system (on my laptop 15 devices are busy).

The fix is to raise the number of devices being manually created.

[adopted from upstream commit 8663d0933439acd8.]
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-09-15 13:17:16 -07:00
Aleksa Sarai 6d06315f20 devmapper: add a test for mount leak workaround
In order to avoid reverting our fix for mount leakage in devicemapper,
add a test which checks that devicemapper's Get() and Put() cycle can
survive having a command running in an rprivate mount propagation setup
in-between. While this is quite rudimentary, it should be sufficient.

We have to skip this test for pre-3.18 kernels.

Signed-off-by: Aleksa Sarai <asarai@suse.de>

[kir@: adopted from upstream commit 1af8ea681fba1935]
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-09-15 12:34:37 -07:00
Sascha Grunert d88ef6dc08
Enable goimports linter and fix lints
Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2020-01-28 15:59:15 +01:00
Nalin Dahyabhai ba598e19f2 Disable cgo-requiring bits when cgo is not enabled
Adjust build tags in drivers and pkg so that builds with CGO_ENABLED=0
won't fail outright.  This ends up disabling btrfs (which uses kernel
headers), ostree (which uses libostree), overlayfs (which uses C headers
to define fs_disk_quota_t), and devicemapper (which uses libdevmapper
and loopback) by default.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-08-05 13:42:50 -04:00
Nalin Dahyabhai 026db3c2bd drivers: make Init() take a graphdriver.Config
Instead of passing the driver-specific directory and assorted fields
from a Config struct to lower-level drivers when we initialize them,
pass them the directory and the Config struct.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-06-20 11:38:33 -04:00
Nalin Dahyabhai c073b43547 Add a CreateFromTemplate() method to drivers, and use it for mapped layers
Add a CreateFromTemplate() method to graph drivers, and use it instead
of a driver-oblivious diff/put method when we want to create a copy of
an image's top layer that has the same parent and which differs from the
original only in its ID maps.

This lets drivers that can quickly make an independent layer based on
another layer do something smarter than we were doing with the
driver-oblivious method.  For some drivers, a native method is
dramatically faster.

Note that the driver needs to be able to do this while still exposing
just one notional layer (i.e., one link in the chain of layers for a
given container) to the higher levels of the APIs, so if the new layer
is actually a child of the template layer, that needs to remain a detail
that's private to the driver.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-01-17 14:28:40 -05:00
Daniel J Walsh da1e7e5d28 Force the user to specify a device when setting up devicemapper
We do not want to fall back on to loop back devices when setting up
devicemapper. We have decided that this causes too many issues, and
we have an excellent default in Overlay to handle first setup.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2018-05-18 11:17:05 -04:00
Nalin Dahyabhai 3da7589326 Add more tests, using vfs as a baseline
Add an "echo" driver test, for making sure that we generate diffs
correctly when particular paths are removed in one layer and restored in
a subsequent one.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2018-02-23 16:00:48 -05:00
Daniel J Walsh 98c480e157 Backport moby devmapper driver changes to containers/storage
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2017-09-26 20:45:15 +00:00
Nalin Dahyabhai 60ff079996 Rename: cow/cowman -> storage/oci-storage
Rename the library module and CLI wrapper.
Rename daemon/graphdriver to drivers.
Catch up vendoring to match modules we've pruned.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2016-07-18 17:35:50 -04:00