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: Use private mounts for btrs polling #21519

Merged
merged 2 commits into from
Jan 15, 2025

Conversation

mvollmer
Copy link
Member

@mvollmer mvollmer commented Jan 14, 2025

In Anaconda mode, Cockpit mounts a btrfs filesystem to list its subvolumes. Now these mounts are private to the process that does the listing, just like the mounts for making changes already are.

Since the mounts are no longer shared, we don't need to maintain a database of their users.

Copy link
Member

@martinpitt martinpitt left a comment

Choose a reason for hiding this comment

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

Thanks! Looking forward to the tests; when I tried to make poll mount points private, I got all kinds of failures. But of course that was just me monkeying around.

pkg/storaged/btrfs/btrfs-tool.py Outdated Show resolved Hide resolved
Comment on lines 94 to 96
def remove_all_tmp_mountpoints():
if len(tmp_mountpoints) > 0:
with mount_database() as db:
for mp in set(tmp_mountpoints):
remove_tmp_mountpoint(db, mp)

for mp in set(tmp_mountpoints):
remove_tmp_mountpoint(mp)
Copy link
Member

Choose a reason for hiding this comment

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

Even this could be dropped. There will only be a handful of directories, they cost next to nothing, and now that they are in /run they won't survive a reboot anyway. (Fine to keep it, just thinking aloud)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I was thinking the same, just wanted to produce a version that does a full cleanup first.

pkg/storaged/btrfs/btrfs-tool.py Show resolved Hide resolved
@martinpitt
Copy link
Member

Yeah, that TestStorageAnaconda.testBtrfs failure happened for me as well when I tried to make everything private. Then I didn't take time to understand why, but I'm sure you still remember 😅

@mvollmer mvollmer force-pushed the storage-private-buttering branch from fa42148 to c613e5c Compare January 15, 2025 10:06
Copy link
Member

@martinpitt martinpitt left a comment

Choose a reason for hiding this comment

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

Thanks! Even through the stopping/starting during the dialog is a bit awkward, it does make sense - we generally treat dialog values as "snapshot in time", and then catch up.

LGTM aside from the debugging leftovers, but let's see what the tests say.

if (btrfs_monitor_channel)
return;

console.log("STARTING");
Copy link
Member

Choose a reason for hiding this comment

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

debugging leftover (more instances below)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I wanted to see them in the logs...

@mvollmer
Copy link
Member Author

Alright, start/stop of the monitor works.

@mvollmer mvollmer force-pushed the storage-private-buttering branch from c613e5c to a3dd43a Compare January 15, 2025 11:20
@mvollmer
Copy link
Member Author

I have removed the cleanup of directories from btrfs-tool as well now.

@mvollmer mvollmer force-pushed the storage-private-buttering branch from a3dd43a to 2d81e51 Compare January 15, 2025 11:22
btrfs_monitor_channel.close();
return res;
} else {
return Promise.resolve();
Copy link
Member Author

Choose a reason for hiding this comment

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

Very good, this means we never try to stop the monitor when it is not actually running.

@mvollmer
Copy link
Member Author

Even through the stopping/starting during the dialog is a bit awkward,

Note that it is only stopped during dialog actions, after clicking "Do it". The monitor keeps running while the dialog is open.

@martinpitt
Copy link
Member

Nice, looking good! Now just remove the two obsolete imports, and we should be good to go? 🚀

In Anaconda mode, Cockpit mounts a btrfs filesystem to list its
subvolumes. Now these mounts are private to the process that does the
listing, just like the mounts for making changes already were.

Since the mounts are no longer shared, we don't need to maintain a
database of their users.

The monitor process stops using its own private mounts as soon as it
detects a real mount of the filesystem. For this to work, these real
mounts need to be visible to the monitor process and thus we need to
make its namespace a "slave".
In Anaconda mode.  This removes any interference from private mounts
during those dialog actions.
@mvollmer mvollmer force-pushed the storage-private-buttering branch from 2d81e51 to bea1a45 Compare January 15, 2025 13:15
@mvollmer mvollmer marked this pull request as ready for review January 15, 2025 13:15
@mvollmer mvollmer requested a review from martinpitt January 15, 2025 13:16
Copy link
Member

@martinpitt martinpitt left a comment

Choose a reason for hiding this comment

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

Cheers!

btrfs_monitor_channel.close();
return res;
} else {
return Promise.resolve();
Copy link
Contributor

Choose a reason for hiding this comment

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

This added line is not executed by any test.

@martinpitt martinpitt merged commit 2eabd3a into cockpit-project:main Jan 15, 2025
86 of 87 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants