From b948bde3d16cd69c16be4a50949a4dba41817fb6 Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Thu, 29 Aug 2024 16:44:31 +0200 Subject: [PATCH] storaged: filter podman btrfs subvolumes Podman btrfs subvolumes are an implementation detail of podman and not interesting for a Cockpit user in the storage page. Closes: #20912 --- pkg/storaged/client.js | 8 +++++++- test/verify/check-storage-btrfs | 24 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/pkg/storaged/client.js b/pkg/storaged/client.js index 628c66f5d151..3cf818b3acaa 100644 --- a/pkg/storaged/client.js +++ b/pkg/storaged/client.js @@ -248,12 +248,18 @@ export async function btrfs_poll() { for (const line of output.split("\n")) { const m = line.match(/ID (\d+).*parent (\d+).*parent_uuid (.*)uuid (.*) path (\/)?(.*)/); if (m) { + const pathname = m[6]; + // Ignore podman btrfs subvolumes, they are an implementation detail. + if (pathname.includes("containers/storage/btrfs/subvolumes")) { + continue; + } + // The parent uuid is the uuid of which this subvolume is a snapshot. // https://github.com/torvalds/linux/blob/8d025e2092e29bfd13e56c78e22af25fac83c8ec/include/uapi/linux/btrfs.h#L885 let parent_uuid = m[3].trim(); // BTRFS_UUID_SIZE is 16 parent_uuid = parent_uuid.length < 16 ? null : parent_uuid; - subvols.push({ pathname: m[6], id: Number(m[1]), parent: Number(m[2]), uuid: m[4], parent_uuid }); + subvols.push({ pathname, id: Number(m[1]), parent: Number(m[2]), uuid: m[4], parent_uuid }); } } uuids_subvols[uuid] = subvols; diff --git a/test/verify/check-storage-btrfs b/test/verify/check-storage-btrfs index 153efbee3b81..5d54c804120e 100755 --- a/test/verify/check-storage-btrfs +++ b/test/verify/check-storage-btrfs @@ -99,6 +99,30 @@ class TestStorageBtrfs(storagelib.StorageCase): b.go("#/") b.wait_visible(self.card("Storage")) + # podman subvolumes are hidden + m.execute(f""" + mkdir -p /var/lib/containers/storage/btrfs/subvolumes + btrfs subvolume create /var/lib/containers/storage/btrfs/subvolumes/containername + + mkdir -p /home/admin/.local/share/containers/storage/btrfs/subvolumes + btrfs subvolume create /home/admin/.local/share/containers/storage/btrfs/subvolumes/grafana + + btrfs subvolume create {subvol_mount_point}/pancake + """) + + b.wait_in_text(self.card_row("Storage", name="pancake"), "btrfs subvolume") + b.wait_not_in_text("div[data-test-card-title='Storage']", "containername") + b.wait_not_in_text("div[data-test-card-title='Storage']", "grafana") + + self.addCleanup(m.execute, """ + btrfs subvolume delete /home/admin/.local/share/containers/storage/btrfs/subvolumes/grafana + btrfs subvolume delete /var/lib/containers/storage/btrfs/subvolumes/containername + + rm -rf /var/lib/containers + rm -rf /home/admin/.local/share/containers + """) + testlib.sit() + # mount outside of fstab, should be cleaned up when re-formatting m.execute(f""" btrfs subvolume create {mount_point}/nonfstab