Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

storage: Disallow volume.security.shared on cephfs #14633

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lxd/storage/drivers/driver_cephfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,8 @@ func (d *cephfs) Validate(config map[string]string) error {
// shortdesc: Whether the CephFS file system was empty on creation time
// scope: global
"volatile.pool.pristine": validate.IsAny,
// Override general 'security.shared' rule since only cephfs does not support block volumes.
"volume.security.shared": func(value string) error { return fmt.Errorf("") },
Copy link
Member

Choose a reason for hiding this comment

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

empty error message looks odd?

}

return d.validatePool(config, rules, nil)
Expand Down
10 changes: 5 additions & 5 deletions test/suites/storage_driver_cephfs.sh
Copy link
Member

Choose a reason for hiding this comment

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

Please can you expand the commit message as to why these were ineffective?

Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ test_storage_driver_cephfs() {
lxc storage delete cephfs

# Test invalid key combinations for auto-creation of cephfs entities.
! lxc storage create cephfs cephfs source="${LXD_CEPH_CEPHFS}/$(basename "${LXD_DIR}")" cephfs.osd_pg_num=32 || true
! lxc storage create cephfs cephfs source="${LXD_CEPH_CEPHFS}/$(basename "${LXD_DIR}")" cephfs.meta_pool=xyz || true
! lxc storage create cephfs cephfs source="${LXD_CEPH_CEPHFS}/$(basename "${LXD_DIR}")" cephfs.data_pool=xyz || true
! lxc storage create cephfs cephfs source="${LXD_CEPH_CEPHFS}/$(basename "${LXD_DIR}")" cephfs.create_missing=true cephfs.data_pool=xyz_data cephfs.meta_pool=xyz_meta || true

! lxc storage create cephfs cephfs source="${LXD_CEPH_CEPHFS}/$(basename "${LXD_DIR}")" cephfs.osd_pg_num=32 || false
! lxc storage create cephfs cephfs source="${LXD_CEPH_CEPHFS}/$(basename "${LXD_DIR}")" cephfs.meta_pool=xyz || false
! lxc storage create cephfs cephfs source="${LXD_CEPH_CEPHFS}/$(basename "${LXD_DIR}")" cephfs.data_pool=xyz || false
! lxc storage create cephfs cephfs source="${LXD_CEPH_CEPHFS}/$(basename "${LXD_DIR}")" cephfs.create_missing=true cephfs.data_pool=xyz_data cephfs.meta_pool=xyz_meta || false
! lxc storage create cephfs cephfs source="${LXD_CEPH_CEPHFS}/$(basename "${LXD_DIR}")" volume.security.shared=true || false

# Test cephfs storage volumes.
for fs in "cephfs" "cephfs2" ; do
Expand Down
16 changes: 14 additions & 2 deletions test/suites/storage_local_volume_handling.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,18 @@ test_storage_local_volume_handling() {
lxc storage volume set "${pool}" vol1 user.foo=snap0
lxc storage volume set "${pool}" vol1 snapshots.expiry=1H

lxc storage volume create "${pool}" blockVol --type=block
truncate -s 25MiB foo.iso
lxc storage volume import "${pool}" ./foo.iso isoVol

# security.shared is only allowed for block volumes
! lxc storage volume set "${pool}" vol1 security.shared true || false
! lxc storage volume set "${pool}" isoVol security.shared true || false
Copy link
Member

Choose a reason for hiding this comment

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

So does security.shared not work for iso volumes because they are allowed to be attached concurrently to multiple instances (as this should be allowed because they are readonly)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, they are sharable by default

lxc storage volume set "${pool}" blockVol security.shared true

lxc storage volume delete "${pool}" blockVol
lxc storage volume delete "${pool}" isoVol

# This will create the snapshot vol1/snap0
lxc storage volume snapshot "${pool}" vol1

Expand Down Expand Up @@ -289,7 +301,6 @@ test_storage_local_volume_handling() {
[ "$(lxc storage volume get "${target_pool}" vol5/snap0 volatile.uuid)" = "${old_snap0_uuid}" ]

# copy ISO custom volumes
truncate -s 25MiB foo.iso
lxc storage volume import "${source_pool}" ./foo.iso iso1
lxc storage volume copy "${source_pool}/iso1" "${target_pool}/iso1"
lxc storage volume show "${target_pool}" iso1 | grep -q 'content_type: iso'
Expand All @@ -308,10 +319,11 @@ test_storage_local_volume_handling() {
lxc storage volume delete "${source_pool}" vol6
lxc storage volume delete "${target_pool}" iso1
lxc storage volume delete "${target_pool}" iso2
rm -f foo.iso
fi
done
done

rm -f foo.iso
)

# shellcheck disable=SC2031,2269
Expand Down
Loading