Commit Graph

154 Commits

Author SHA1 Message Date
Valentin Rothberg fe15d204d3 overlay: allow storing images with more than 127 layers
Note that such images can now be stored but they cannot be
pushed yet.  Supporting both use cases would be ideal for
source-container images that are known to have a large number
of layers, likely exceeding the current limit of 127 layers.

This limit is inherited from Docker to proactively restrict the
amount and size of arguments passed when mounting.  All (lower)
layers must be specified at mount-time but we only have one page
to pass them.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2019-12-09 16:54:50 +01:00
Zac Medico f39fb8370d Remove redundant if statements for nil slices
Suggested-by: Daniel J Walsh <dwalsh@redhat.com>
Signed-off-by: Zac Medico <zmedico@gmail.com>
2019-11-22 13:02:42 -08:00
Zac Medico 5fc095c06d VFS support for user.* xattrs
Preservation of user.* xattrs is supported by most (if not all) other
drivers, and it's especially useful for containers that run under a
PaX kernel where "user.pax.flags" is used to store PaX flags.

Signed-off-by: Zac Medico <zmedico@gmail.com>
2019-11-20 22:15:20 -08:00
Daniel J Walsh f3c3a0abee
Fix to be able to build on FTBFS on mipsel
Some platforms store s.Rdev as unit32, translate to unit64 so it
will compile.

Also add function to make it clear that the object is a whiteout object.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-11-11 17:27:49 -05:00
Giuseppe Scrivano 82fd61f670
overlay: use fusermount to unmount FUSE file systems
when a mountProgram is used, attempt to unmount the file system using
fusermount or fusermount3.

If the FUSE writeback cache is used (fuse-overlayfs uses it by default
since version 0.5), some changes might not be flushed from the kernel
to the FUSE file system.

Using umount we could lose these changes as the file system is
terminated before these changes are visible to the FUSE file system.

Going through fusermount|fusermount3 instead makes sure FUSE flushes
all the pending requests before the file system is unmounted.

If the fusermount attempts fail, make sure the file system is flushed
before being unmounted.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-11-04 16:36:04 +01:00
Giuseppe Scrivano d577584dd5
overlay: check for FUSE when using mountProgram
if a mountProgram is specified, check that the file system is already
mounted using the FUSE magic number instead of overlay.  It enables
using fuse-overlayfs on top of overlay.

Closes: https://github.com/containers/storage/issues/447

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-10-30 09:45:56 +01:00
Giuseppe Scrivano 37930824fb
config: drop skip_mount_home
it was needed only with OSTree to allow hard links.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-10-05 20:27:46 +02:00
Giuseppe Scrivano 7a0d58dab5
storage: drop ostree deduplication
it was an attempt to use OSTree to deduplicate files, at the time we
already had a dependency on OSTree for system containers in
containers/image.  Since the feature never really took off, let's just
drop it.

Closes: https://github.com/containers/storage/issues/419

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-10-05 20:27:45 +02:00
Daniel J Walsh e3f1fe0cb3
Ignore ro mount options in btrfs and windows drivers
Since now we always set the "ro" mount option, we need to ignore
these options on drivers that do not support them.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-08-09 11:26:02 -04:00
Daniel J Walsh e96cd8656f
Naive diff should pass in the ro option on parent directory
If we are just mounting the parent directory, we should do it read
only.  We should not use the upper and work directory.

If there is only one lower directory we should return that path.  No
reason to mount the lower directory at all.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-08-06 08:37:29 -04:00
Daniel J Walsh ae728c0b20
Don't report IsNotExists errors, when unmounting
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-08-05 20:29:04 -04:00
Daniel J Walsh 161c94f448
Merge pull request #410 from nalind/no-cgo
Disable cgo-requiring bits when cgo is not enabled
2019-08-05 20:25:46 -04: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
Kevin Pelzel a2f32f9dbf Removing need to specify storage driver when using ignore_chown_errors option
Signed-off-by: Kevin Pelzel <kevinpelzel22@gmail.com>
2019-08-05 09:52:50 -06:00
Daniel J Walsh 4ab853cbec
We should not be touching internal work dir
Vivek Goyal says that we should not be touching the internal WorkDir/work directory.
This is internal to the kernel and should not be modified.  I believe this was done
to make sure that the "/" of the container is writable by the root user of the user
namespace that is running the container.  Changing the ownership of the diffDir
should give us the same behavior and is safe to do.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-08-03 07:46:38 -04:00
Daniel J Walsh fa580f0747
Add support for ignoreChownErrors to vfs
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-07-29 14:30:17 -04: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
Peter Hunt e835f5f185 overlay: fix small piece of repeated work
we compute d.dir(id) twice, but store the value the first time. use the cached value instead.

Signed-off-by: Peter Hunt <pehunt@redhat.com>
2019-07-25 12:03:07 -04:00
Daniel J Walsh 138592c82b
Remove merged directory when it is unmounted
This should cause the kernel to clear any leaked mount points into other
containers.

Also create the merged directory every time you attempt to create it.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-07-17 10:45:23 -04:00
Danila Kiver fe0e9e0b58 Remove unfinished VFS layer if its creation fails.
Current implementation of VFS driver performs the copy of the parent
layer during the creation of new (child) layer, but does not clean
the destination if the copy process fails.

From the consuming application perspective, this make storage leaks
possible, e.g. an attempt to create new container with podman,
if failed in the middle of the copy due to disk overflow, leaves
unfinished container layer stray.

To avoid obliging the application (or the end user) to take care of
such possible leaks, cleanup is added.

Signed-off-by: Danila Kiver <danila.kiver@mail.ru>
2019-06-29 14:33:39 +03:00
Giuseppe Scrivano a7a6b097c7
quota: add build tag to disable it
change backported from Moby.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-06-27 12:54:46 +02:00
Nalin Dahyabhai b967c52ea7 overlay: cache supported/using-metacopy/use-naive-diff
Use the feature cache to track whether or not overlay is supported,
whether or not metacopy is on (for a specific set of mount options), and
whether or not we can use native diff (again, for a specific set of
mount options).

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-06-20 11:38:33 -04:00
Nalin Dahyabhai 8fed8037c5 drivers/overlay: add feature cache functions
Add a few helper functions for caching and checking whether or not
particular features are enabled/supported.  Most calls to them happen
before the Driver is allocated, so they're functions that take a runhome
directly rather than methods of the Driver.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-06-20 11:38:33 -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
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
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
Daniel J Walsh 89a7ad744a
Fix crash on tesing of aufs code
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-05-20 15:11:22 -04:00
Giuseppe Scrivano 5995d88179
chown: do not change owner for the mountpoint
This is already done by the driver when creating the directory, so we
will end up trying to map IDs that were already mapped.

regression introduced with d1554f0dcd
and 7c6d502e9b.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-05-15 17:02:31 +02:00
Daniel J Walsh ef42340c2e
Revert "Add MountTempFromSource and RemoveTemp interfaces"
This reverts commit e9695564db.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-05-02 11:54:55 -04:00
Daniel J Walsh 91cf837e44
Merge branch 'master' of github.com:containers/storage 2019-05-02 10:36:36 -04:00
Nalin Dahyabhai 8d7b848bcb Compilation fixes
Add a couple of quick compilation fixes.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-05-01 23:37:07 -04:00
Giuseppe Scrivano d1554f0dcd
overlay: use the layer idmapping if present
prefer the custom idmapping specified for the layer instead of using
the global one configured for the driver.

Closes: https://github.com/containers/libpod/issues/2960

Signed-off-by: Giuseppe Scrivano <giuseppe@scrivano.org>
2019-05-01 18:46:07 +02:00
Giuseppe Scrivano 7c6d502e9b
vfs: prefer layer custom idmappings
Signed-off-by: Giuseppe Scrivano <giuseppe@scrivano.org>
2019-05-01 18:46:06 +02:00
Giuseppe Scrivano 77065edb97
layers: propagate down the idmapping settings
when creating a layer, propagate down the idmapping.

Signed-off-by: Giuseppe Scrivano <giuseppe@scrivano.org>
2019-05-01 18:31:19 +02:00
Urvashi Mohnani 2581a719d5 Fix up recreateSymlink
Noticed that the link directory may be lost also with the symlinks,
so this fix creates it if not found and then restores all the links.
Also fix up logic to check wether a dir is found or not instead of
a regular file.

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
2019-04-29 18:00:10 -04:00
Daniel J Walsh e9695564db
Add MountTempFromSource and RemoveTemp interfaces
These interfaces can be used to setup a graphdriver mountpoint
of the source directory for use within a container.
The RemoveTemp interface umounts the mountpoint and then removes
all of the modified data in the graphdriver for this source directory.

The primary use case of these interfaces is for container engines that
want to mount a directory from the host system into the container. The
source dirctory then can be modified without actually changing the
directory on the host.

Containers will use these interfaces for sharing packaing cache directories
like /var/cache/dnf, to help speed up container builds.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-04-29 14:46:40 -04:00
Nalin Dahyabhai 42c08c2767 overlay: fix single-lower test
The multiple-lowers test in the overlay driver succeeded even when we
didn't pass in an upper or work directory, because it can be used for
read-only cases even then, but the single-lower test definitely needs us
to provide upper and work directories, so do that.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-04-25 12:52:50 -04:00
Urvashi Mohnani 4906488081 Recreate symlink when not found
If the synlinks under /var/lib/containers/storage/overlay/l are lost
during a sudden reboot, we go through all the layers under the overlay
directory and create symlinks point to their respective diff directories
with the same name as they were created before. We get this name from
the "link" file under each layer dir.

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
2019-04-24 12:16:24 -04:00
Giuseppe Scrivano 1336305582
overlay: propagate errors from mountProgram
propagate the mountProgram stderr output if the mount failed.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-04-23 15:25:47 +02:00
Daniel J Walsh ab043e226b
Evaluate device path for lvm
We have a bug report where a user specified a symbolic link to storage
driver.  The issue is the physical device is not predictable but the link
is, so evaluating sym links makes the symlink path supportable.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-04-15 05:57:51 -04:00
Valentin Rothberg f240cc75a0 drivers.DirCopy: fix filemode detection
We failed to detect char devices as those were not covered by the
`ModeDevice` check.  Fix this by using the entire FileMode mask as
suggested by the standard library.

Also change the "unknown file type" error to include the mode to
ease debugging potential regressions in the future.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2019-04-05 15:12:54 +02:00
Nalin Dahyabhai 6a9fa6b66e drivers/copy: add a non-cgo fallback
The vfs driver already has logic that avoids use of the copy package
when we're not on Linux, so provide the same fallback in the copy
package for non-cgo cases.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-03-26 10:03:04 -04:00
Giuseppe Scrivano 86147bc774
storage: make [l]chown errors clearer
if os.[Lc,C]hown are failing with EINVAL, it might be related to an
UID/GID not mapped in the user namespace we are currently using.

It could be possible to detect this issue by inspecting
/proc/self/uid_map or /proc/self/gid_map, but that won't be possible
when we are pulling a new image and extracting it from a chroot where
/proc is not mounted.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-03-11 08:56:38 +01:00
Nalin Dahyabhai 771658dbb8 Make use of overlay.override_kernel_check a warning instead of an error
When we removed all traces of override_kernel_check, we created a
situation where older configuration files would suddenly start causing
us to emit an error at startup.  Soften that to a warning, for now at
least.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-02-12 13:58:36 -05:00
Giuseppe Scrivano 308b57a78f
overlay: do not attempt metacopyup when using a mount program
Signed-off-by: Giuseppe Scrivano <giuseppe@scrivano.org>
2019-01-21 10:10:25 +01:00
Daniel J Walsh 891018027e
Merge pull request #271 from nalind/template-layers
drivers: add CreateFromTemplate()
2019-01-18 10:56:56 -05:00
Daniel J Walsh e03971bbe3
Merge pull request #268 from nalind/metacopy-check
overlay: check if metacopy is happening
2019-01-17 17:33:25 -05:00
Nalin Dahyabhai d0e8054e55 overlay: make template results sort-of children
Make layers based on template layers actually be children of the
template layer, so that we don't need to copy the diff to create them.
Upper layers should be making sure that we don't remove the template
layer before we attempt to remove the new layer.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-01-17 14:32:52 -05: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
Nalin Dahyabhai 05c69f1b2a overlay: check if metacopy is happening
In the overlay driver, check if metacopy is enabled, and report it along
with other status information.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-01-17 14:14:10 -05:00