Skip to content

Conversation

mheon
Copy link
Member

@mheon mheon commented Feb 27, 2025

DO NOT MERGE until c/storage containers/storage#2264 merges.

Fixes #25368

Does this PR introduce a user-facing change?

Fixed a bug where volume quotas were not being applied.

@openshift-ci openshift-ci bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note labels Feb 27, 2025
@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 27, 2025
skip_if_rootless "Quotas are only possible with root"

loop=$PODMAN_TMPDIR/loopdevice
dd if=/dev/zero of=$(loopfile) bs=1M count=25
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$loop here instead of $(loopfile)?

Comment on lines 655 to 660
umount $vol_path
losetup -d $loop_dev
rm -f $loop
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine for the quick test now but before merging it should be reworked to use a teardown function.
The reason is if anything in the test fails the cleanup here will never be run and we leak the loop devices.

Look at the test/system/180-blkio.bats test, maybe it is easiest to just place you test in that file as teardown() applies to all tests in the file.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes me really miss defer() as we really should be adding the cleanup functions one at a time as we do the create/losetup/mount/etc

@mheon mheon force-pushed the fix_25368 branch 8 times, most recently from 8ff2b0a to 612a37b Compare February 27, 2025 22:03
Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make sure the cleanup works correctly, you can easily test this locally
hack/bats --root -T 160:"podman volumes with XFS quotas" then check that no mounts are leaked on the system when you add failure points at any place in the test.

Comment on lines 626 to 631
# Minimum XFS filesystem size is 300mb
loop=$PODMAN_TMPDIR/loopdevice
dd if=/dev/zero of=$loop bs=1M count=300
loop_dev=$(losetup -f)
losetup $loop_dev $loop
mkfs.xfs $loop_dev
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

    # Minimum XFS filesystem size is 300mb
    loop=$PODMAN_TMPDIR/disk.img
    fallocate -l 300m  ${loop}
    run -0 losetup -f --show $loop
    loop_dev="$output"
    mkfs.xfs $loop_dev

This should be a bit more race safe I think and we may not have to copy 300mb of zeros.

And I still think you need to move this to 180 and then add proper teardown logic to unmount the fs and loop device.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you object to me adding a 161-volume-quotas.bats and throwing this test in there along with the cleanup? I hesitate to throw things in unrelated files

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am fine with a new file

run_podman 1 $safe_opts exec $ctrname dd if=/dev/zero of=/two/onemb bs=1M count=1
assert "$output" =~ "No space left on device"

run_podman rm -f -t 0 $ctrname
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is missing $safe_opts, this brings us to another cleanup problem.
Normally the default teardown takes care of deleting cotnainers. However as you used $safe_opts it has no idea they exist and the container is leaked so the tearodwn will have to deal with that as well.

ctrname="testctr"
run_podman $safe_opts run -d --name=$ctrname -i -v $vol_one:/one -v $vol_two:/two $IMAGE top

run_podman $safe_opts exec $ctrname dd if=/dev/zero of=/one/onemb bs=1M count=1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small nit, make the MB upper case then it will be easier to see the different file names and what they represent

@mheon mheon changed the title [WIP] Fix #25368 Fix #25368 Feb 28, 2025
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 28, 2025
@mheon
Copy link
Member Author

mheon commented Feb 28, 2025

Dropping WIP as c/storage patch is merged

@mheon
Copy link
Member Author

mheon commented Feb 28, 2025

@Luap99 If we backport this, I don't think we strictly need the c/storage patch given it's just tightening restrictions on how the quota function is invoked; agree?

Includes a patch for quotas that is needed for this PR.

Signed-off-by: Matt Heon <mheon@redhat.com>
@Luap99
Copy link
Member

Luap99 commented Feb 28, 2025

@Luap99 If we backport this, I don't think we strictly need the c/storage patch given it's just tightening restrictions on how the quota function is invoked; agree?

If the test passes without the c/storage change sure, not having to do backports in c/storage will make it much easier.

Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please document the xfsprogs requirement in test/system/README.md and also add it to the test rpm package requirements (rpm/podman.spec line 145+)
While it is likely that xfs is always on fedora by default better safe then having to deal with failing gating tests due the missing mkfs.xfs

This resolves an ordering issue that prevented quotas from being
applied. XFS quotas are applied recursively, but only for
subdirectories created after the quota is applied; if we create
`_data` before the quota, and then use `_data` for all data in
the volume, the quota will never be used by the volume.

Also, add a test that volume quotas are working as designed using
an XFS formatted loop device in the system tests. This should
prevent any further regressions on basic quota functionality,
such as quotas being shared between volumes.

Fixes containers#25368

Signed-off-by: Matt Heon <mheon@redhat.com>
@Luap99 Luap99 changed the title Fix #25368 Fix volume quota assignment Feb 28, 2025
Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

openshift-ci bot commented Feb 28, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Luap99, mheon

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@rhatdan
Copy link
Member

rhatdan commented Mar 1, 2025

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Mar 1, 2025
@openshift-merge-bot openshift-merge-bot bot merged commit efe8e16 into containers:main Mar 1, 2025
91 checks passed
@stale-locking-app stale-locking-app bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label May 31, 2025
@stale-locking-app stale-locking-app bot locked as resolved and limited conversation to collaborators May 31, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

XFS Quota Enforcement Issue: Only Applied at Volume Root, Not Inside _data for Second and Subsequent Podman Volumes
3 participants