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

storaged: filter podman btrfs subvolumes #20956

Merged
merged 1 commit into from
Sep 2, 2024
Merged
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
8 changes: 7 additions & 1 deletion pkg/storaged/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (<FS_TREE>\/)?(.*)/);
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;
Expand Down
15 changes: 15 additions & 0 deletions test/verify/check-storage-btrfs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,21 @@ class TestStorageBtrfs(storagelib.StorageCase):
b.go("#/")
b.wait_visible(self.card("Storage"))

# podman subvolumes are hidden, Cockpit hides everything matching "containers/storage/btrfs/subvolumes"
m.execute(f"""
mkdir -p /run/kitchen/containers/storage/btrfs/subvolumes
btrfs subvolume create /run/kitchen/containers/storage/btrfs/subvolumes/containername

mkdir -p /run/kitchen/.local/share/containers/storage/btrfs/subvolumes
btrfs subvolume create /run/kitchen/.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")

# mount outside of fstab, should be cleaned up when re-formatting
m.execute(f"""
btrfs subvolume create {mount_point}/nonfstab
Expand Down