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

snapshots: Improve memory path handling #1730

Merged
merged 1 commit into from
Sep 12, 2024

Conversation

mvollmer
Copy link
Member

@mvollmer mvollmer commented Jul 18, 2024

Demo: https://www.youtube.com/watch?v=wyrBSaIb93k

  • We only ask for the directory of the memory snapshot, not for the full filename. That way we don't have to worry about what to do when the user changes the name and it makes more sense when we talk about how much space is available "at this location". Also, people don't have to worry about the filenames for disk snapshots, why would they worry about them for the memory part?
  • The default for the memory save location is also taken from previous snapshots. That way, people only have to change it for the first snapshot when they are not happy with putting it next to the primary disk.
  • The snapshot name does not need to include the VM name. Snapshots are already scoped to VMs.
  • The memory save file gets the extension ".save", to mirror what "virsh managedsave" is doing.

Machines: Improvements to snapshots of running machines

The snapshot of a running machine includes its memory state, and Cockpit sometimes asks where to store it. This is now done in a slightly improved fashion: you only need to specify the directory, and Cockpit will provide the name of the file. The default for this directory now also takes previous snapshots into account, so that you don't need to touch it if you always store the memory state of all snapshots in the same directory. Plus, Cockpit now gives estimates for the amount of space that will be needed and warns you if there doesn't seem to be enough.

screenshot

@mvollmer
Copy link
Member Author

Previous version of the dialog:

image

@mvollmer
Copy link
Member Author

It's not yet clear to me how to compute the estimate for the maximum size of the memory save file.

In my experiments, the file size corresponds pretty closely with the memory usage shown by Cockpit. A snapshot taken while compiling the kernel consistently used 2 GB on disk, for a VM with 2 GB RAM. A snapshot of a freshly booted machine that showed 500 MB RAM usage (out of 2 GB) in Cockpit used 450 MB for the memory snapshot.

So I guess we can use the current memory usage as the estimate. Or to be conservative, we can use the total RAM.

@mvollmer mvollmer force-pushed the snapshots-memorypath-polish branch from 245caff to e6d3102 Compare July 19, 2024 07:34
@mvollmer mvollmer requested a review from garrett July 19, 2024 08:08
@mvollmer mvollmer force-pushed the snapshots-memorypath-polish branch from e6d3102 to 5746ff7 Compare July 19, 2024 08:43
@mvollmer mvollmer force-pushed the snapshots-memorypath-polish branch 2 times, most recently from 7724d82 to 5cd4b06 Compare July 19, 2024 12:17
@mvollmer mvollmer marked this pull request as ready for review July 19, 2024 12:18
@mvollmer mvollmer force-pushed the snapshots-memorypath-polish branch 3 times, most recently from db058b4 to e2fdd3c Compare July 19, 2024 13:34
@mvollmer
Copy link
Member Author

@garrett, what do you think of this?

@mvollmer mvollmer added no-test and removed no-test labels Jul 30, 2024
@mvollmer mvollmer force-pushed the snapshots-memorypath-polish branch 6 times, most recently from d2bc635 to 6d15eda Compare July 31, 2024 07:52
@mvollmer mvollmer force-pushed the snapshots-memorypath-polish branch 2 times, most recently from 9d705dd to d29ac9b Compare August 29, 2024 08:43
@mvollmer
Copy link
Member Author

mvollmer commented Sep 5, 2024

Generally, it's better to prefer non-jargon text when possible and to avoid exposing implementation details.

Yeah. We can also omit the "RAM state location" completely and always just use a sensible default.

@mvollmer
Copy link
Member Author

mvollmer commented Sep 5, 2024

I'm asking for us to start adopting top labelling for modals.

Alright, let's do it! :-)

@mvollmer
Copy link
Member Author

mvollmer commented Sep 5, 2024

libvirt calls these files "RAM state" too, according to https://wiki.libvirt.org/Snapshots.html
[...]
if we did want to say something like "Memory state directory".

Here is the high-level description of the various snapshotting things that libvirt can do, and it doesn't mention "RAM", only "memory", and more specifically calls it "guest memory".

Cockpit only uses "memory" in its UI and not "RAM".

So we should stick with "memory".

"Guest memory state file directory" or "Guest memory state file location" would be most descriptive (if a bit ridiculous) and with top labels we have the space.

I'll change it to "Memory state file location", and change this dialog to use top-labels. All others are done in #1804.

@mvollmer mvollmer force-pushed the snapshots-memorypath-polish branch 2 times, most recently from 8c18d48 to 4ec946d Compare September 5, 2024 06:31
@mvollmer
Copy link
Member Author

mvollmer commented Sep 5, 2024

I'll change it to "Memory state file location", and change this dialog to use top-labels. All others are done in #1804.

Done, and updated the screenshot in the description.

@mvollmer mvollmer force-pushed the snapshots-memorypath-polish branch 3 times, most recently from 80dc5fe to 66768e1 Compare September 9, 2024 11:41
@mvollmer mvollmer requested a review from jelly September 10, 2024 07:07
@mvollmer mvollmer force-pushed the snapshots-memorypath-polish branch 3 times, most recently from 681addd to 2e6a750 Compare September 10, 2024 08:52
@mvollmer mvollmer force-pushed the snapshots-memorypath-polish branch 2 times, most recently from a623d6b to 67fd9b7 Compare September 10, 2024 10:23
garrett
garrett previously approved these changes Sep 10, 2024
Copy link
Member

@garrett garrett left a comment

Choose a reason for hiding this comment

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

I think this PR is fine to merge.

But we should consider if we want to move to top-labelling overall and have side labelling be the exception, or have top-labelling be the exception. Naturally, things should be internally consistent (that is: the same in the same context; for example: this modal should have all labels be the same way, like it does).

Considering PatternFly uses top labeling by default, that's another argument aside from strings, to use that.

 - We only ask for the directory of the memory snapshot, not for the
   full filename.

 - The default for the memory save location is taken from previous
   snapshots.

 - The default snapshot name does not include the VM name.

 - Available and needed storage space is shown in the dialog.

 - New directories can be created from the dialog.

 - The memory save file gets the extension ".save", to mirror what
   "virsh managedsave" is doing.
} else {
if (vm.connectionName === LIBVIRT_SYSTEM_CONNECTION)
return "/var/lib/libvirt/memory/" + snapName;
return "/var/lib/libvirt/memory";
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.

else if (current_user)
return current_user.home + "/.local/share/libvirt/memory/" + snapName;
return current_user.home + "/.local/share/libvirt/memory";
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.

const info = JSON.parse(output);
callback(info.free * info.unit);
})
.catch(exc => {
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.

})
.catch(exc => {
// channel has already logged the error
callback(null);
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.

mpath = mpath + "/";
mpath = mpath + vm.name + "." + name + ".save";
}
const superuser = (vm.connectionName === LIBVIRT_SYSTEM_CONNECTION) ? "require" : false;
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.

const validationError = this.onValidate();

const body = (
<Form onSubmit={e => e.preventDefault()} isHorizontal>
<Form onSubmit={e => e.preventDefault()}>
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.

export function dirname(path) {
const i = path.lastIndexOf("/");
if (i < 0)
return ".";
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.

if (i < 0)
return ".";
else if (i == 0)
return "/";
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.

@jelly
Copy link
Member

jelly commented Sep 11, 2024

Looks fairly good to me, but on ubuntu there are some test flakes?

@mvollmer
Copy link
Member Author

Looks fairly good to me, but on ubuntu there are some test flakes?

Yes, let's see.

@jelly jelly merged commit e1d3bb8 into cockpit-project:main Sep 12, 2024
27 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.

5 participants