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

Confirmation dialog for VM shutdown, forceoff, reboot and non-maskable interrupt #1069

Merged
merged 3 commits into from
Jun 26, 2023

Conversation

skobyda
Copy link
Contributor

@skobyda skobyda commented May 5, 2023

Machines: Confirm shutdown actions

Ask for confirmation for every action which can cause downtime. The modal also shows uptime to help user from accidentally taking down a VM with a long uptime.

248766553-adebffd9-af32-4f24-9121-45ba8bc06540

src/components/vm/vmActions.jsx Outdated Show resolved Hide resolved
src/components/vm/vmActions.jsx Show resolved Hide resolved
src/components/vm/vmActions.jsx Outdated Show resolved Hide resolved
@garrett
Copy link
Member

garrett commented May 8, 2023

This is nice progress so far.

Kind of a huge omission right now: Where's the VM's name? How do you know what you're shutting down or restarting?

@skobyda
Copy link
Contributor Author

skobyda commented May 11, 2023

This is nice progress so far.

Kind of a huge omission right now: Where's the VM's name? How do you know what you're shutting down or restarting?

Oh right, forgot about it. Updated it:

Screenshot from 2023-05-11 02-22-30

@skobyda skobyda requested a review from garrett May 11, 2023 00:26
@skobyda skobyda force-pushed the confirmShutdown branch 3 times, most recently from 3cb456b to 0527c4d Compare May 15, 2023 12:17
@skobyda skobyda marked this pull request as ready for review May 15, 2023 12:17
@martinpitt
Copy link
Member

@skobyda Just in case you didn't see, there's still several test failures here.

@skobyda skobyda force-pushed the confirmShutdown branch 5 times, most recently from ae7a9ca to 8d4755c Compare May 16, 2023 12:12
@skobyda skobyda force-pushed the confirmShutdown branch 4 times, most recently from 02b9445 to 2582cda Compare May 25, 2023 10:51
@skobyda
Copy link
Contributor Author

skobyda commented May 25, 2023

Also, if VM was started as a result of some secondary operation, e.g. snapshot-revert, migration let's show the message next to it. We don't know for how long has the VM been running before, since after snapshot-revert or migration, the new VM instance is spawned:
Screenshot from 2023-05-25 11-17-53

@skobyda skobyda force-pushed the confirmShutdown branch 4 times, most recently from a0487c8 to 0f349f5 Compare June 21, 2023 19:36
Comment on lines 251 to 252
handler: () => {
setOperationInProgress(true);
onReboot(vm);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh this one could have a test. Everything else not really relevant. Will have look at that tomorrow.

@skobyda skobyda requested review from garrett and removed request for garrett June 22, 2023 08:26
@skobyda skobyda force-pushed the confirmShutdown branch 2 times, most recently from 1466199 to 1377147 Compare June 22, 2023 17:16
@skobyda
Copy link
Contributor Author

skobyda commented Jun 23, 2023

@garrett Hey, mind giving this a review? I decided not to include the message which says that VM is running x time since snapshot revert (e.g. like seen in this screenshot), because there was some race condition it tests related to that (I need to look at that more). Now the UI only shows that VM is running x time (without saying what was the reason for VM startup), e.g. like this:
Screenshot from 2023-06-23 11-34-35

@skobyda skobyda force-pushed the confirmShutdown branch 3 times, most recently from c77bda8 to 327dbba Compare June 23, 2023 09:42
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.

Somewhat minor: Is there a way to make the labels "fluid" width, so it'd look like this?

image

If you could do that, it would be wonderful. Either in this PR or as a followup.

Additionally, the title should have a question (note: and it shouldn't be bold; only the title of the machine should be) according to PF docs.

https://www.patternfly.org/v4/components/modal/design-guidelines#confirmation-dialogs

@skobyda
Copy link
Contributor Author

skobyda commented Jun 26, 2023

@garrett Fixed:

Screenshot from 2023-06-26 12-32-48

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! Some nitpicks which are optional, but the error handling nees fixing.

src/libvirtApi/domain.js Outdated Show resolved Hide resolved
src/libvirtApi/domain.js Outdated Show resolved Hide resolved
src/libvirtApi/domain.js Outdated Show resolved Hide resolved
src/components/vm/confirmDialog.jsx Outdated Show resolved Hide resolved
src/components/vm/confirmDialog.jsx Outdated Show resolved Hide resolved
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.

Thanks for the changes! LGTM! 👍

@skobyda skobyda force-pushed the confirmShutdown branch 2 times, most recently from 72ede35 to ca21440 Compare June 26, 2023 12:46
useEffect(() => {
return domainGetStartTime({ connectionName: vm.connectionName, vmName: vm.name })
.then(res => setUptime(res))
.catch(e => console.error(JSON.stringify(e)));
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 +84 to +91
const onReboot = (vm) => domainReboot({ name: vm.name, id: vm.id, connectionName: vm.connectionName }).catch(ex => {
store.dispatch(
updateVm({
connectionName: vm.connectionName,
name: vm.name,
error: {
text: cockpit.format(_("VM $0 failed to reboot"), vm.name),
detail: ex.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 8 added lines are not executed by any test. Details

Comment on lines +97 to +104
const onForceReboot = (vm) => domainForceReboot({ name: vm.name, id: vm.id, connectionName: vm.connectionName }).catch(ex => {
store.dispatch(
updateVm({
connectionName: vm.connectionName,
name: vm.name,
error: {
text: cockpit.format(_("VM $0 failed to force reboot"), vm.name),
detail: ex.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 8 added lines are not executed by any test. Details

Comment on lines +111 to +120
.then(() => !vm.persistent && cockpit.location.go(["vms"]))
.catch(ex => {
setOperationInProgress(false);
store.dispatch(
updateVm({
connectionName: vm.connectionName,
name: vm.name,
error: {
text: cockpit.format(_("VM $0 failed to shutdown"), vm.name),
detail: ex.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 10 added lines are not executed by any test. Details

Comment on lines +126 to +133
const onPause = (vm) => domainPause({ name: vm.name, id: vm.id, connectionName: vm.connectionName }).catch(ex => {
store.dispatch(
updateVm({
connectionName: vm.connectionName,
name: vm.name,
error: {
text: cockpit.format(_("VM $0 failed to pause"), vm.name),
detail: ex.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 8 added lines are not executed by any test. Details

Comment on lines +139 to +146
const onResume = (vm) => domainResume({ name: vm.name, id: vm.id, connectionName: vm.connectionName }).catch(ex => {
store.dispatch(
updateVm({
connectionName: vm.connectionName,
name: vm.name,
error: {
text: cockpit.format(_("VM $0 failed to resume"), vm.name),
detail: ex.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 8 added lines are not executed by any test. Details

Comment on lines +154 to +161
.catch(ex => {
store.dispatch(
updateVm({
connectionName: vm.connectionName,
name: vm.name,
error: {
text: cockpit.format(_("VM $0 failed to force shutdown"), vm.name),
detail: ex.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 8 added lines are not executed by any test. Details

Comment on lines +167 to +174
const onSendNMI = (vm) => domainSendNMI({ name: vm.name, id: vm.id, connectionName: vm.connectionName }).catch(ex => {
store.dispatch(
updateVm({
connectionName: vm.connectionName,
name: vm.name,
error: {
text: cockpit.format(_("VM $0 failed to send NMI"), vm.name),
detail: ex.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 8 added lines are not executed by any test. Details

* - /var/log/libvirt/qemu/ - For privileged (qemu:///system) VMs
* - ~/.cache/libvirt/qemu/logs - For non-privileged (qemu:///session) VMs
*/
const logFile = connectionName === "system" ? `/var/log/libvirt/qemu/${vmName}.log` : `${loggedUser.home}/.cache/libvirt/qemu/log/${vmName}.log`;
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

@skobyda skobyda requested a review from martinpitt June 26, 2023 15:19
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.

Thank you! PLease update the screenshots in the description for the release note, and reformat the text.

// 2023-05-05 11:22:03.043+0000: starting up libvirt version: 8.6.0, package: 3.fc37 (Fedora Project, 2022-08-09-13:54:03, ), qemu version: 7.0.0qemu-7.0.0-9.fc37, kernel: 6.0.6-300.fc37.x86_64, hostname: fedora

// Alternatively regex line.match(/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/g) can be used
const timeStr = line.split(': starting')[0];
Copy link
Member

Choose a reason for hiding this comment

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

Note to self: due to | tail -1 the script will never fail. line will then be empty, and thus timeStr will also be empty.

Comment on lines +37 to +38
.then(res => setUptime(res))
.catch(e => console.error(JSON.stringify(e)));
Copy link
Member

Choose a reason for hiding this comment

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

As per above, domainGetStartTime() now returns '' if it didn't find any time. Thus the .catch will never happen (and console.error is fine then, as second-level defense), but it will call setUptime('').

AFAICS this is handled correctly below.

@martinpitt martinpitt dismissed stale reviews from garrett and KKoukiou June 26, 2023 19:21

Garrett +1'ed above

@martinpitt martinpitt merged commit d58afde into cockpit-project:main Jun 26, 2023
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