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: Allow creation of swap and maintain fstab entries #19843

Merged
merged 1 commit into from
Jan 19, 2024

Conversation

mvollmer
Copy link
Member

@mvollmer mvollmer commented Jan 15, 2024


Storage: improved support for swap

Cockpit can now format block devices as swap and will maintain a fstab entry for them.

@mvollmer
Copy link
Member Author

@marusak For excellent swap support also in the normal Cockpit mode, we would need to write entries for swap devices into fstab, maintain their "noauto" option depending on whether the device is active, do some "misswapping" warnings, and remove the entry during teardown. That's entirely possible, but might not be worth the effort. Opinions?

@mvollmer mvollmer marked this pull request as ready for review January 15, 2024 12:43
@mvollmer mvollmer requested a review from marusak January 15, 2024 12:44
@jelly
Copy link
Member

jelly commented Jan 15, 2024

@marusak For excellent swap support also in the normal Cockpit mode, we would need to write entries for swap devices into fstab, maintain their "noauto" option depending on whether the device is active, do some "misswapping" warnings, and remove the entry during teardown. That's entirely possible, but might not be worth the effort. Opinions?

In my own opinion I would like this to be fully supported in Cockpit (even if it is dying tech most distro's nowadays only use zram/zswap). Keeping the amount of custom Anaconda features low would a good thing to strive for in my opinion.

@mvollmer mvollmer marked this pull request as draft January 15, 2024 16:50
@mvollmer
Copy link
Member Author

In my own opinion I would like this to be fully supported in Cockpit (even if it is dying tech most distro's nowadays only use zram/zswap).

Yes, that's the right thing to do(tm), let's do it.

@mvollmer mvollmer force-pushed the storage-make-swap branch 2 times, most recently from a81d732 to 3ab49c7 Compare January 16, 2024 09:07
@mvollmer mvollmer changed the title storage: Allow formatting as swap in Anaconda mode storage: Allow creation of swap and maintain fstab entries Jan 16, 2024
@mvollmer mvollmer marked this pull request as ready for review January 16, 2024 13:17
@mvollmer mvollmer force-pushed the storage-make-swap branch 3 times, most recently from db745eb to 6aab047 Compare January 17, 2024 08:41
@jelly
Copy link
Member

jelly commented Jan 17, 2024

Some issues I found:

  • Creating a swap partition on /dev/sda does not work (no partition table) this should be a valid use case:
[root@fedora-39-127-0-0-2-2201 ~]# mkswap /dev/sda
Setting up swapspace version 1, size = 4 GiB (4294963200 bytes)
no label, UUID=934afe18-e205-4bfe-96f2-ec4a76edd783
  • Swap on LVM suffers the same issue
  • Swap on stratis?

@mvollmer
Copy link
Member Author

  • Creating a swap partition on /dev/sda does not work (no partition table)

Oh, you mean there is a JavaScript exception? Good catch! Fixed!

@mvollmer
Copy link
Member Author

  • Swap on stratis?

That's not possible, stratis only has filesystems, no?

@jelly
Copy link
Member

jelly commented Jan 17, 2024

  • Swap on stratis?

That's not possible, stratis only has filesystems, no?

Ah ok, then nvm!

@jelly
Copy link
Member

jelly commented Jan 17, 2024

  • Creating a swap partition on /dev/sda does not work (no partition table)

Oh, you mean there is a JavaScript exception? Good catch! Fixed!

Yup, blocks_ptable doesn't exist for a plain /dev/sda. Thanks!

jelly
jelly previously approved these changes Jan 17, 2024
Copy link
Member

@jelly jelly left a comment

Choose a reason for hiding this comment

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

Looks good, one comment about a potential missing test.

test/verify/check-storage-swap Show resolved Hide resolved
@jelly
Copy link
Member

jelly commented Jan 18, 2024

Just realized this is release note worthy so marked it as such.

m.execute(f"mkswap -f {disk}")
b.click(self.card_button("Swap", "Start"))
b.wait_text(self.card_desc("Swap", "Used"), "0")
self.assertIn("defaults", m.execute(f"findmnt --fstab -n -o OPTIONS {disk}"))
Copy link
Member

Choose a reason for hiding this comment

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

This check seems to be a bit racy fails on both Arch and debian-testing

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, clicking "Start" will first activate the Swap and then add the fstab entry. So it is feasible that the "Used" number appears before the fstab entry. I changed this into a testlib.wait.

Copy link
Member

@jelly jelly left a comment

Choose a reason for hiding this comment

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

Unfortunately one part of the test seems to be flaky.

Copy link
Member

@jelly jelly left a comment

Choose a reason for hiding this comment

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

Approved, re-triggered rhel-8-10-distropkg/storage hopefully it was just a busy test vm.

@@ -423,6 +429,8 @@ function format_dialog_internal(client, path, start, size, enable_dos_extended,
else if (trigger == "type") {
if (dlg.get_value("type") == "empty") {
dlg.update_actions({ Variants: action_variants_for_empty });
} else if (dlg.get_value("type") == "swap") {
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. Details

@@ -450,6 +458,12 @@ function format_dialog_internal(client, path, start, size, enable_dos_extended,
partition_type = "21686148-6449-6e6f-744e-656564454649";
}

if (type == "swap") {
partition_type = (block_ptable && block_ptable.Type == "dos"
? "0x82"
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. Details

Comment on lines +616 to +619
if (keep_keys) {
const content_block = client.blocks_cleartext[path];
return client.blocks_swap[content_block.path];
} else if (is_encrypted(vals))
Copy link
Contributor

Choose a reason for hiding this comment

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

These 4 added lines are not executed by any test. Details

return client.blocks_swap[content_block.path];
} else if (is_encrypted(vals))
return (client.blocks_cleartext[path] &&
client.blocks_swap[client.blocks_cleartext[path].path]);
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. Details

if (type == "swap" && mount_now)
return (client.wait_for(() => block_swap_for_block(path))
.then(block_swap => block_swap.Start({})));
if (is_encrypted(vals) && (is_filesystem(vals) || type == "swap") && !mount_now)
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. Details

@@ -284,6 +284,12 @@ export function get_resize_info(client, block, to_fit) {
grow_needs_unmount: false
};
shrink_excuse = _("VDO backing devices can not be made smaller");
} else if (client.blocks_swap[block.path]) {
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. Details

["fstab", {
dir: { t: 'ay', v: encode_filename("none") },
type: { t: 'ay', v: encode_filename("swap") },
opts: { t: 'ay', v: encode_filename(noauto ? "noauto" : "defaults") },
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. Details

@@ -910,6 +911,15 @@ export function get_active_usage(client, path, top_action, child_action, is_temp
enter_unmount(children[c], c, false);
enter_unmount(block, mp, true);
});
} else if (swap) {
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. Details

@jelly jelly merged commit 42522f9 into cockpit-project:main Jan 19, 2024
92 of 93 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