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

vm: Support for VM descriptions #1644

Merged
merged 1 commit into from
Sep 6, 2024

Conversation

mvollmer
Copy link
Member

@mvollmer mvollmer commented May 20, 2024

Based on work by @Britz, thanks a lot!

This is also a proving ground for robust and convenient virt-xml invocations. I plan to renovate the rest of domain.js and other files accordingly.

The description is a <p> so that it doesn't get too shouty when people put a lot of text there.

"Edit description" action:

image


Machines: Support for VM descriptions

Cockpit can now show and change the descriptions of virtual machines.

screenshot-page

screenshot

@mvollmer mvollmer requested a review from garrett May 20, 2024 14:06
@mvollmer mvollmer force-pushed the vm-titles-and-description branch 7 times, most recently from a2a1286 to d9dc7b9 Compare May 22, 2024 05:29
@mvollmer mvollmer marked this pull request as ready for review May 22, 2024 05:29
@mvollmer mvollmer requested a review from martinpitt May 22, 2024 05:29
@martinpitt
Copy link
Member

This looks a bit sad, retrying for comparison.

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! Depending on how much time you can/want to throw at this, I can be convinced to give a +1. But I'm not super happy about this just yet.

src/components/vm/vmRenameDialog.jsx Outdated Show resolved Hide resolved
src/libvirtApi/domain.js Outdated Show resolved Hide resolved
test/check-machines-lifecycle Outdated Show resolved Hide resolved
src/components/vm/vmRenameDialog.jsx Outdated Show resolved Hide resolved
@mvollmer mvollmer force-pushed the vm-titles-and-description branch 3 times, most recently from 3d21e50 to feb47bf Compare May 22, 2024 14:10
@martinpitt
Copy link
Member

Yay for the new pixel test!

@martinpitt
Copy link
Member

Very cool, thanks! Looks good, just needs the new pixel test mopped up.

martinpitt
martinpitt previously approved these changes May 28, 2024
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.

Ah, I was about to mop up the pixel update, but you already did it -- I didn't see the force-push here. Force-pushed a rebase, and re-running the tests to check the flakes.

LGTM, assuming green. Thanks!

@martinpitt
Copy link
Member

This still needs a proper release note, but otherwise looks good to land. Thanks!

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 thought this was already discussed before and we specifically decided to not do it this way. (Note: it was different people working on cockpit-machines at that point in time.)

A VM is not a person with a first, middle, and last names. It does not have a "Full name".

If we want to get around the limitation for the name that serves as a type of identifier (ID) for the VM, then we should have "Name" be a display name and generate the machine's unique and limited (in characters) name based on the display name. I believe that's the intent for this, to work around an implementation detail where the name itself is restricted to various limits (mainly, which characters it can use).

It does not makes sense to have yet another field to do the exact same thing. We already have name for a way to identify the machine and description to explain what it does. Having both will be confusing and also take up extra space everywhere where there's a name, for no good reason.


So, instead of having the split here's how we might handle it instead:

Completely move the short ID name to the background, have it based on the display name, and always show the display name (treating the non-display name as an implementation detail). We could always set both the display name and ID name or only set the display if it doesn't fit within the ID's restrictions.

When displaying VMs, we'd do something like "display name || ID name" where it would default to showing the display name (if it exists) and falling back to the ID name if a display name is not shown. And we could even do something where we transform the display name to the ID name and if they match, only show display name, else show "Display name (ID name)". I think we're already doing this (if it already exists) without a way to set it, right?

@martinpitt
Copy link
Member

Completely move the short ID name to the background

I'm not a fan of this TBH. The name which we currently display is the one you'd see in virsh list, use on the CLI, etc. I find the whole concept of adding yet another name a bit dubious TBH -- it's rather obscure, feels like "too much human-y fiddling" and redundant. libvirt calls this "title", which sounds even worse than "full name" to me at least.

I was screptical about this already, and @garrett 's comments pushed me over the line. How about we entirely drop this title/full name again, and only retain the optional description? That seems marginally more useful to me, and isn't so much "in your face" and redundant.

@martinpitt martinpitt dismissed their stale review May 28, 2024 08:58

design still being discussed

@mvollmer
Copy link
Member Author

only retain the optional description?

Makes sense to me.

@mvollmer
Copy link
Member Author

@garrett's design also makes a lot of sense to me. :-)

@mvollmer
Copy link
Member Author

only retain the optional description?

Makes sense to me.

But does it then make sense to use the Rename dialog to set the description?

@martinpitt
Copy link
Member

Good point -- dang, looks like this is back to square one wrt. design then? 😢

@mvollmer mvollmer marked this pull request as ready for review June 20, 2024 10:04
@mvollmer
Copy link
Member Author

We should probably read the description from that, and not from the "online", "running" XML.

Done. (It's called the "inactive" definition.)

@mvollmer
Copy link
Member Author

This failure is a new flake... let's see.

@mvollmer
Copy link
Member Author

This failure is a new flake... let's see.

One apparently can't ever use set_val with React components. Fixed by using set_input_text. It can in fact create multiple lines, but one has to use "\r" instead of "\n".

@martinpitt
Copy link
Member

@vollmer: Please don't use \r and \n in set_input_text() or b.input_text() any more, this isn't portable across browsers. Use b.key("Enter") or similar.

@mvollmer
Copy link
Member Author

@vollmer: Please don't use \r and \n in set_input_text() or b.input_text() any more, this isn't portable across browsers. Use b.key("Enter") or similar.

Hmm, can we make it so that set_input_text("\n") does the right thing? I'll make a PR.

@mvollmer
Copy link
Member Author

@vollmer: Please don't use \r and \n in set_input_text() or b.input_text() any more, this isn't portable across browsers. Use b.key("Enter") or similar.

Hmm, can we make it so that set_input_text("\n") does the right thing? I'll make a PR.

The test now dioes this:

        b.set_input_text("#edit-description-dialog-description", desc1, value_check=False, blur=False)
        b.key("Enter")
        b.set_input_text("#edit-description-dialog-description", desc2, value_check=False, append=True)
        b.wait_val("#edit-description-dialog-description", desc1 + "\n" + desc2)

It would be really nice to replace that with

        b.set_input_text("#edit-description-dialog-description", desc1 + "\n" + desc2)

Not only because it is less to type, but also because this is the natural first thing to try, and it is not at all obvious what to do once you figure out that it doesn't work.

Based on work by @Britz, thanks a lot!
@mvollmer
Copy link
Member Author

mvollmer commented Sep 5, 2024

Whoops, dropped the ball on this, sorry. Let's get this back on track.

based on the discussion above, this PR leaves "title" and "id" alone. It is only about the description now.

The description of a VM is shown on the details page, and there is an action in the menu to edit it. The description of this PR is up-to-date with the code.

Copy link

We were not able to find or create Copr project packit/cockpit-project-cockpit-machines-1644 specified in the config with the following error:

Packit received HTTP 500 Internal Server Error from Copr Service. Check the Copr status page: https://copr.fedorainfracloud.org/status/stats/, or ask for help in Fedora Build System matrix channel: https://matrix.to/#/#buildsys:fedoraproject.org.

Unless the HTTP status code above is >= 500, please check your configuration for:

  1. typos in owner and project name (groups need to be prefixed with @)
  2. whether the project name doesn't contain not allowed characters (only letters, digits, underscores, dashes and dots must be used)
  3. whether the project itself exists (Packit creates projects only in its own namespace)
  4. whether Packit is allowed to build in your Copr project
  5. whether your Copr project/group is not private

@mvollmer mvollmer requested a review from jelly September 5, 2024 11:44
Comment on lines +44 to +47
} catch (exc) {
dialogErrorSet({
dialogError: cockpit.format(_("Failed to set description of VM $0"), vm.name),
dialogErrorDetail: exc.message
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.

Comment on lines +67 to +69
<Form onSubmit={e => {
e.preventDefault();
onSubmit();
Copy link
Contributor

Choose a reason for hiding this comment

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

These 3 added lines are not executed by any test.

onSubmit();
}}
isHorizontal>
{!isObjectEmpty(error) && <ModalError dialogError={error.dialogError} dialogErrorDetail={error.dialogErrorDetail} />}
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.

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.

One small comment/question, otherwise looks good (!)

@@ -888,6 +888,33 @@ export function domainSendNMI({
return call(connectionName, objPath, 'org.libvirt.Domain', 'InjectNMI', [0], { timeout, type: 'u' });
}

function shlex_quote(str) {
// yay, command line apis...
return "'" + str.replaceAll("'", "'\"'\"'") + "'";
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

@mvollmer mvollmer Sep 6, 2024

Choose a reason for hiding this comment

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

Yeah, what about it? :-) This is supposed to be a JavaScript implementation of it. Is something missing?

Copy link
Member

Choose a reason for hiding this comment

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

Mistaken this for a Python file, don't ask :)


# Non-ascii chars, unbalanced quotes, backslash, multiple lines
desc1 = '"Döscrü\\ptiän \'\'\' كرة القدم'
desc2 = 'Second <b>line</b>'
Copy link
Member

Choose a reason for hiding this comment

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

I hope this does not get rendered as such :)

Copy link
Member Author

Choose a reason for hiding this comment

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

It gets rendered as text, not as HTML.

image

@mvollmer mvollmer requested review from jelly and cockpituous and removed request for cockpituous and garrett September 6, 2024 07:17
@mvollmer mvollmer dismissed garrett’s stale review September 6, 2024 07:20

Addressed by not showing/setting the title at all

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.

Cool!

@mvollmer mvollmer merged commit afd6141 into cockpit-project:main Sep 6, 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