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

Restoring snapshot causes VM to go to suspended state #1629

Closed
isaranova opened this issue Sep 9, 2022 · 5 comments
Closed

Restoring snapshot causes VM to go to suspended state #1629

isaranova opened this issue Sep 9, 2022 · 5 comments

Comments

@isaranova
Copy link

Versions:
ovirt-engine-4.5.2.5-0.1.el8ev.noarch
ovirt-web-ui-1.9.1-1.el8ev.noarch
firefox-104.0-5.fc36.x86_64

Steps to Reproduce:

  1. Have a VM (powered off)
  2. Create a snapshot for the VM
  3. Click on the restore icon of that snapshot (confirm restore)
  4. Check VM state after the restore

Actual results:
VM is suspended.

Expected results:
VM is still powered off.

Additional info:
This isn't happening in Admin Portal.

image

@sgratch
Copy link
Member

sgratch commented Sep 13, 2022

This is well reproduced on oVirt >= 4.5.2 as a result of this fix oVirt/ovirt-engine#516

And specifically due to this line fix: https://github.com/ahadas/ovirt-engine/blob/6ce8656a5817302f1ce4e81cdbd5951630299e6d/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/snapshots/SnapshotsManager.java#L460-L462

    `vmDynamic.setStatus(withMemory ? VMStatus.Suspended : VMStatus.Down);`

Since for snapshots created via web-ui, withMemory is always set to true, regardless to the way the snapshot was created, i,e, even if it was created with no memory included.

Details

When restoring a snapshot via web-ui:

  1. the web-ui doesn't mention the restore_memoryparameter as part of the restore post query http://ovirt.github.io/ovirt-engine-api-model/master/#services/snapshot/methods/restore
  2. and the default on rest api in that case is restore_memory = true as shown here
    https://github.com/oVirt/ovirt-engine/blob/41851f27e401c3a47d6c94f70f278cb4fbc59bdc/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendSnapshotResource.java#L60-L63
    https://github.com/oVirt/ovirt-engine/blob/41851f27e401c3a47d6c94f70f278cb4fbc59bdc/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/TryBackToAllSnapshotsOfVmParameters.java#L23
  3. Please note that the restore itself does check if the actual memory is included in the snapshot and if it can be restored or not, so there wasn't a bug in restoring, even though web-ui send a missing API request for restoring memory of snapshots that doesn't include it.
  4. After this bug fix Set VMs that preview memory snapshots to suspended ovirt-engine#516, the VM is always set to suspend status since it always asked to restore a memory of a snapshot.

Solution

It seems that a fix should be done on web-ui by adding the restore_memory parameter to the restore endpoint.
We do have this value within snapshot.get('persistMemoryState') so just need to pass it to Api.restoreSnapshot.

ahadas added a commit to ahadas/ovirt-engine that referenced this issue Sep 13, 2022
Previously, when trying-back/restoring a snapshot that doesn't have
memory while the client requested to restore memory, the VM would
have switched to Suspended state.

Now, the VM is set to Suspended only when the active snapshot, the
snapshot that was created by the trying-back/restore operation, is
set with memory volumes. Otherwise, the VM is set to Down.

See: oVirt/ovirt-web-ui#1629

Signed-off-by: Arik Hadas <ahadas@redhat.com>
@ahadas
Copy link
Member

ahadas commented Sep 13, 2022

It seems that a fix should be done on web-ui by adding the restore_memory parameter to the restore endpoint. We do have this value within snapshot.get('persistMemoryState') so just need to pass it to Api.restoreSnapshot.

Since the API is also affected by this, it's better to solve it on the backend side

ahadas added a commit to ahadas/ovirt-engine that referenced this issue Sep 14, 2022
Previously, when trying-back/restoring a snapshot that doesn't have
memory while the client requested to restore memory, the VM would
have switched to Suspended state.

Now, the VM is set to Suspended only when the active snapshot, the
snapshot that was created by the trying-back/restore operation, is
set with memory volumes. Otherwise, the VM is set to Down.

See: oVirt/ovirt-web-ui#1629

Signed-off-by: Arik Hadas <ahadas@redhat.com>
@sjd78
Copy link
Member

sjd78 commented Sep 15, 2022

Ok so it sounds like if a VM snapshot is restored, the VM can end up with a state of:

  • Down ... if the snapshot does not include memory
  • Down ... if the snapshot includes memory, but the restore_memory action flag is set false
  • Suspended ... if the snapshot include memory, and restore_memory action flag is true (explicitly or by default of not false)

Engine PR oVirt/ovirt-engine#516 touched it and PR oVirt/ovirt-engine#653 looks to be fixing the issue underlying this issue.

@isaranova - Is that your understanding? If you restore a VM snapshot with memory on webadmin, does the VM end in the Suspended status? If you restore a VM snapshot without memory on web-ui, does the VM end in Down status?

I'm guessing this issues isn't really an issue and what you're seeing is just the way it is supposed to work now.

@sgratch - From web-ui, if the VM is running, a snapshot can be created with memory. That attribute does flow through the snapshot create action. The persistMemoryState internal param name transforms to persist_memorystate in the action. Here is the create modal with memory:
image

On the restore action, the service and web-ui defaults to restoring the memory (if available in the snapshot) by not explicitly specifying the parameter in the action POST. API doc: http://ovirt.github.io/ovirt-engine-api-model/master/#services/snapshot/methods/restore. I don't think it make sense to say "don't restore the memory even if it exists" just to force all restores to leave a VM down.

@ahadas - I agree with your assessment. The issue, if there actually is one, is best handled on the backend/engine side.

ahadas added a commit to oVirt/ovirt-engine that referenced this issue Sep 15, 2022
Previously, when trying-back/restoring a snapshot that doesn't have
memory while the client requested to restore memory, the VM would
have switched to Suspended state.

Now, the VM is set to Suspended only when the active snapshot, the
snapshot that was created by the trying-back/restore operation, is
set with memory volumes. Otherwise, the VM is set to Down.

See: oVirt/ovirt-web-ui#1629

Signed-off-by: Arik Hadas <ahadas@redhat.com>
@sgratch
Copy link
Member

sgratch commented Sep 21, 2022

@sjd78 @isaranova
Before latest fix on backend oVirt/ovirt-engine#653, there was a bug on rest/web-ui since the actual memory inclusion for the snapshot was not checked via rest and therefore whenever a snapshot was restored via rest/web-ui, the restore_memory action flag was set to true by default and therefore the vm was always suspended.

On webamdin it worked as expected and suspended only when memory was really included.

The current behavior after the fix should be the same for webadmin and web-ui as follows:
If a VM snapshot is restored, the vm status will end up with the status of

  1. suspend - if the active snapshot includes memory.
  2. down - if the active snapshot doesn't include memory.

The restore_memory action flag is not relevant anymore for this flow via web-ui/rest.

@sgratch
Copy link
Member

sgratch commented Sep 21, 2022

@isaranova @santos1709 the fix was done on engine backend so closing and moving the ticket to QE's verification, just to make sure that it's fixed for web-ui use case.

@sgratch sgratch closed this as completed Sep 21, 2022
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

No branches or pull requests

4 participants