Commit Graph

88 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
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 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
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 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
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 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 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
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
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
Nalin Dahyabhai bd6cac944a Remove the last traces of the "override_kernel_check" option
The logic that depended on override_kernel_check was changed to test for
the feature at runtime, so we don't need to be suggesting to people that
they need to set this option, or that the option is even a thing.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-01-16 16:59:39 -05:00
Daniel J Walsh 47527d8408
Use mount options when mounting the chown layer.
If we set metacopyup flag in storage.conf, we need to use
this field, when creating the intermediate storage layer.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-01-13 10:59:02 -05:00
baude 9039004752 handle ENOSPC for overlay driver
when detecting if the overlay driver can be used a temporary file is
created.  if the system is ENOSPC, that fails but the error message
response was misleading.  this patch makes the error message in that
case more obvious.

Signed-off-by: baude <bbaude@redhat.com>
2019-01-03 07:59:31 -06:00
Daniel J Walsh ad0f9c4dfa
Merge pull request #237 from giuseppe/fix-extract-in-namespace
archive: propagate InUserNS option to storage-untar
2018-12-03 13:17:26 -05:00
Giuseppe Scrivano 76c57dcfc6
overlay: set InUserNS
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2018-11-29 16:40:40 +01:00
Daniel J Walsh ab6be50561
Allow the passing in and retrieval of mount options
We want to allow tools like podman/buildah to override default storage
container mount options on a container by container basis.

For example if the default mount options for containers/storage include
nodev or nosuid, we want to allow podman to turn these off if the user
specifies --privileged.

We also might want to turn off certain user namespace flags that will cause
buildah and podman build to work slower when creating container images.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2018-11-19 19:14:21 -05:00
Giuseppe Scrivano cd40ccc956
overlay: use AUFS whiteout format when using mount_program
an unprivileged user doesn't have the permission to use mknod (except
in file systems owned by the user itself, e.g. tmpfs), so the unpack
would always fail with EPERM.  Use the AUFS whiteout format that
doesn't require CAP_MKNOD.

Closes: https://github.com/containers/buildah/issues/1160

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2018-11-12 10:50:15 +01:00
Giuseppe Scrivano 9db914d2fa
overlay: force naiveDiff when using a mount program
Overlay diff relies on the kernel's Overlay driver, if a user
specifies an alternative driver then we need to default back to the
naivediff.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2018-10-30 12:39:20 +01:00
Daniel J Walsh ab4364860e
Pass mount options to useNaiveDiff
If in storage.conf I set the mount options to:
mountopt = "nodev,metacopy=on,redirect_dir=on"
This will turn on redirect_dir but the useNaiveDiff does not currently check
this option.  This will cause container images on commit to not be saved
correctly.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2018-10-25 15:33:00 -04:00
Daniel J Walsh 59f4aa4674
Change useNaiveDiff into driver function
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2018-10-25 15:23:11 -04:00
Giuseppe Scrivano 49b6a634ad
overlay: don't check backing fs when using a mount program
Closes: https://github.com/containers/storage/issues/221

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2018-10-16 12:22:12 +02: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 06cea37b86
tests: add test for shifting support
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2018-07-27 17:24:19 +02: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
Giuseppe Scrivano 648024562d
overlay: enable support for shifting when FUSE is used
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2018-07-26 06:12:38 +02:00
Giuseppe Scrivano 8c814e0070
overlay: use full paths to the mount program
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2018-07-26 06:11:49 +02:00
Daniel J Walsh 2569af9a00
Fix overlay to handle mountopt properly
We need to translate the mount options into flags or
data, so this PR makes the parse code public so we can
use it in containers/storage.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2018-07-25 16:52:03 -04:00
Daniel J Walsh 8b1a0f8d68
Add default mount options to pass to drivers
I believe we should be running container images mounted with nodev by default.
This would eliminate the disk of a device sneaking into the container without
being on the approved list.  This would give us the same or potentially additional
security over the device cgroup.

It would be nice if this could be passed in on an image by image basis.  So users
could also specify if they want nosuid images.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2018-07-18 10:20:27 -04:00
Giuseppe Scrivano e933db5962
storage: rename fuse_program to mount_program
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2018-07-16 17:20:55 +02:00