Commit Graph

26 Commits

Author SHA1 Message Date
Miloslav Trmač 35b3e0f41b Avoid unnecessary manually-coded loops
Use the "slices", "maps" standard library packages, or other
readily-available features.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-09-05 19:45:45 +02:00
Jan Rodák e73dbaaaf3
Fix errcheck: error return value of `driver.Put` is not checked
Signed-off-by: Jan Rodák <hony.com@seznam.cz>
2024-07-09 14:34:07 +02:00
Akihiko Odaki 18136c586b overlay: Test user.fuseoverlayfs.override_stat handling
Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
2024-06-11 15:36:10 +09:00
Michael Vogt 40f19b73aa graphtest: skip tests on insufficient permissions
When a graphdriver cannot be tested because of e.g. `ErrIncompatibleFS`
it is skipped. However this seems not to be the case for permission
error and when running the tests as user they fail with:
```
chown: ... operation not permited
```
This commit changes the test code to account for this as well and
skip when there are insufficient permissions.

Signed-off-by: Michael Vogt <michael.vogt@gmail.com>
2023-12-22 09:35:29 +01:00
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
Nalin Dahyabhai 88be36b839 DriverTestSetQuota: Put() after Get()
Convention for tests is that they Put() any layers they Get().  Fix this
omission in DriverTestSetQuota() and change the layer name from
"zfsTest" to "quotaTest", because we have quota support on more than
just zfs.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2023-03-31 13:58:24 -04:00
Miloslav Trmač a1ccc9d862 Use os.WriteFile instead of ioutil.WriteFile
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-09-12 16:31:34 +02:00
Miloslav Trmač 23bac7e055 Use os.MkdirTemp instead of ioutil.TempDir
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-09-12 16:30:47 +02:00
Sascha Grunert 3455d12729
Switch to golang native error wrapping
We now use the golang error wrapping format specifier `%w` instead of the
deprecated github.com/pkg/errors package.

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2022-07-07 13:22:46 +02:00
Giuseppe Scrivano e2dae5ea97
graphtest: use unique names for the file system layers
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-04-28 17:38:35 +02:00
Miloslav Trmač 43d63f276a Use math/rand.Rand.Read instead of unsafe slice manipulation
The slice manipulation _is_ actually almost 50% faster,
but the implementation is only correct for sizes that are
a multiple of 8, the use of unsafe is somewhat scary, and
there's only exactly one caller, with the total difference
in the order of tens of milliseconds.

Let's do the simple thing instead.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2021-11-19 08:00:18 +01:00
Nalin Dahyabhai 4ccbebd656 graphtest: expect 0555 permissions
When testing graph drivers, update the expected permission on the root
directory of an empty layer to reflect changes made to the overlay
driver.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2021-02-24 16:44:51 -05:00
Daniel J Walsh 976fe22092
Add storage options to IgnoreChownErrors
Modified patch of Kevin Pelzel.

Also changed ApplyDiff to take new ApplyDiffOpts Struct.

Signed-off-by: Kevin Pelzel <kevinpelzel22@gmail.com>
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-07-26 06:05:27 -04:00
Nalin Dahyabhai fe3d4bcf9b drivers.Options: pass RunRoot in, too
Pass the library-level RunRoot in as part of the Config struct that we
pass to lower-level driver initialization functions.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-06-20 11:38:33 -04:00
Daniel J Walsh b0f0361251
Cleanup hang on unit tests
Currently unit tests seem to be hanging

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-05-22 04:26:10 -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 b6ccc0acfa
Add MountOpts to stop adding fields to Get Interface
This patch adds a MountOpts field to the drivers so we can simplify
the interface to Get and allow additional options to be passed in the future.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2018-10-05 09:23:46 -04:00
Giuseppe Scrivano 1897396330
drivers: inform Mount of the mappings used by the container
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2018-07-26 06:12:42 +02:00
Nalin Dahyabhai 97326e1d2f Support for per-container uid/gid mapping: lower
Expose reading and writing ID mapping in the archive and chrootarchive
packages, and in the driver interface.  Generally this means that
when computing or applying diffs, we need to have ID mappings passed in
that are specific to the layers we're using.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2018-04-03 10:34:32 -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 5a785c73f4 Pass MountLabel down to diff drivers
Currently when we do a commmit, we are mounting the container without using
the mountlabel.  In certain situations we can leak mount points where the
image is already mounted with a label.  If you then attempt to commit the
image, the kernel will attempt to mount the image without a label.  The
kernel will reject this mount since SELinux does not allow the same image
to be mounted with different labels.

Passing down the label to the diff drivers, fixes this issue.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2018-02-06 13:42:25 -05:00
Daniel J Walsh 38e45fb8e2 Backport moby graphtest changes to containers/storage
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2017-09-26 20:45:15 +00:00
Nalin Dahyabhai 5375906c2e Wrap some driver-level errors
Wrap graphdriver.{ErrNotSupported,ErrPrerequisites,ErrIncompatibleFS}
errors in contexts using github.com/pkg/errors, and dig them out for
comparison using errors.Cause().

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-07-10 14:48:46 -04:00
Daniel J Walsh 850e2bcf3b Remove "docker" strings from container storage
We want to make sure that content created out of container storage
does not refer to docker.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2017-01-26 09:47:23 +01: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