19 Commits

Author SHA1 Message Date
23ab7b858a Set quota on volume root directory, not _data
This will appease the higher-level quota logic. Basically, to
find a free quota ID to prevent reuse, we will iterate through
the contents of the directory and check the quota IDs of all
subdirectories, then use the first free ID found that is larger
than the base ID (the one set on the base directory). Problem:
our volumes use a two-tier directory structure, where the volume
has an outer directory (with the name of the actual volume) and
an inner directory (always named _data). We were only setting the
quota on _data, meaning the outer directory did not have an ID,
and the ID-choosing logic thus never detected that any IDs had
been allocated and always chose the same ID.

Setting the ID on the outer directory with PROJINHERIT set makes
the ID allocation logic work properly, and guarantees children
inherit the ID - so _data and all contents of the volume get the
ID as we'd expect.

No tests as we don't have a filesystem in our CI that supports
XFS quotas (setting it on / needs kernel flags added).

Fixes https://issues.redhat.com/browse/RHEL-18038

Signed-off-by: Matt Heon <mheon@redhat.com>
2024-10-22 08:49:56 -04:00
a65aecd260 podman volume rm --force: fix ABBA deadlock
We cannot get first the volume lock and the container locks. Other code
paths always have to first lock the container and the lock the volumes,
i.e. to mount/umount them. As such locking the volume fust can always
result in ABBA deadlocks.

To fix this move the lock down after the container removal. The removal
code is racy regardless of the lock as the volume lcok on create is no
longer taken since commit 3cc9db8626 due another deadlock there.

Fixes #23613

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-08-15 11:07:27 +02:00
5656ad40b1 libpod: use fileutils.(Le|E)xists
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-04-19 09:52:14 +02:00
72f1617fac Bump Go module to v5
Moving from Go module v4 to v5 prepares us for public releases.

Move done using gomove [1] as with the v3 and v4 moves.

[1] https://github.com/KSubedi/gomove

Signed-off-by: Matt Heon <mheon@redhat.com>
2024-02-08 09:35:39 -05:00
2a2d0b0e18 chore: delete obsolete // +build lines
Signed-off-by: Oleksandr Redko <Oleksandr_Redko@epam.com>
2024-01-04 11:53:38 +02:00
e9e18acd5f Merge pull request #20451 from rhatdan/volume
Support size option when creating tmpfs volumes
2023-10-24 15:40:50 +00:00
bad25da92e libpod: add !remote tag
This should never be pulled into the remote client.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-10-24 12:11:34 +02:00
ee60708880 Support size option when creating tmpfs volumes
Fixes: https://github.com/containers/podman/issues/20449

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-10-23 16:31:54 -04:00
979c77f10e Volume create - fast exit when ignore is set and volume exists
Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
2023-10-01 16:54:24 +03:00
f256f4f954 Use constants for mount types
Inspired by https://github.com/containers/podman/pull/19238

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-07-14 07:17:21 -04:00
2c9f18182a The removeContainer function now accepts a struct
We had something like 6 different boolean options (removing a
container turns out to be rather complicated, because there are a
million-odd things that want to do it), and the function
signature was getting unreasonably large. Change to a struct to
clean things up.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2023-06-01 16:27:27 -04:00
bc1a31ce6d Make RemoveContainer return containers and pods removed
This allows for accurate reporting of dependency removal, but the
work is still incomplete: pods can be removed, but do not report
the containers they removed as part of said removal. Will add
this in a subsequent commit.

Major note: I made ignoring no-such-container errors automatic
once it has been determined that a container did exist in the
first place. I can't think of any case where this would not be a
TOCTOU - IE, no reason not to ignore them. The `--ignore` option
to `podman rm` should still retain meaning as it will ignore
errors from containers that didn't exist in the first place.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2023-06-01 16:24:56 -04:00
e8d7456278 Add an API for removing a container and dependencies
This is the initial stage of implementation. The current API
functions but does not report the additional containers and pods
removed. This is necessary to properly display results to the
user after `podman rm --all`.

The existing remove-dependencies code has been removed in favor
of this more native solution.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2023-06-01 15:32:50 -04:00
2ec11b16ab Fix various integration test issues with SQLite state
Two main changes:
- The transient state tests relied on BoltDB paths, change to
  make them agnostic
- The volume code in SQLite wasn't retrieving and setting the
  volume plugin for volumes that used one.

Signed-off-by: Matt Heon <mheon@redhat.com>
2023-03-15 14:45:18 -04:00
ad8a96ab95 Support running nested SELinux container separation
Currently Podman prevents SELinux container separation,
when running within a container. This PR adds a new
--security-opt label=nested

When setting this option, Podman unmasks and mountsi
/sys/fs/selinux into the containers making /sys/fs/selinux
fully exposed. Secondly Podman sets the attribute
run.oci.mount_context_type=rootcontext

This attribute tells crun to mount volumes with rootcontext=MOUNTLABEL
as opposed to context=MOUNTLABEL.

With these two settings Podman inside the container is allowed to set
its own SELinux labels on tmpfs file systems mounted into its parents
container, while still being confined by SELinux. Thus you can have
nested SELinux labeling inside of a container.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-03-13 14:21:12 -04:00
b5a99e0816 Must use mountlabel when creating builtin volumes
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-03-09 12:36:52 -05:00
734c435e01 Add podman volume create --ignore
This ignores the create request if the named volume already exists.
It is very useful when scripting stuff.

Signed-off-by: Alexander Larsson <alexl@redhat.com>
2022-10-24 17:30:31 +02:00
359e397443 libpod: Add volume support for FreeBSD
[NO NEW TESTS NEEDED]

Signed-off-by: Doug Rabson <dfr@rabson.org>
2022-09-27 16:31:40 +01:00
065474755b libpod: Move runtime_volume_linux.go to runtime_volume_common.go
[NO NEW TESTS NEEDED]

Signed-off-by: Doug Rabson <dfr@rabson.org>
2022-09-27 16:31:40 +01:00