Bug 1734699

Summary: Engine-setup fails if there are VMs with snapshots
Product: Red Hat Enterprise Virtualization Manager Reporter: Andrej Krejcir <akrejcir>
Component: ovirt-engineAssignee: Yedidyah Bar David <didi>
Status: CLOSED ERRATA QA Contact: Guilherme Santos <gdeolive>
Severity: high Docs Contact:
Priority: high    
Version: 4.3.5CC: agajania, amashah, aoconnor, bilias, bugs, didi, emarcus, lleistne, oliver.albl, Rhev-m-bugs
Target Milestone: ovirt-4.3.5-2Keywords: ZStream
Target Release: 4.3.5Flags: lsvaty: testing_plan_complete-
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Upgrading the Red Hat Virtualization Manager to version 4.3.5 failed during the configuration stage (engine-setup) when the previous setup included virtual machine snapshots created with Red Hat Virtualization 4.2 or earlier. In this release, the upgrade process succeeds.
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-08-26 09:59:14 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Integration RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Andrej Krejcir 2019-07-31 09:00:41 UTC
Description of problem:
When updating an existing environment were some VMs have snapshots, the engine-setup fails.

The log contains error:

2019-07-30 14:24:31,117+0000 DEBUG otopi.context context._executeMethod:145 method exception
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/otopi/context.py", line 132, in _executeMethod
    method['method']()
  File "/usr/share/ovirt-engine/setup/bin/../plugins/ovirt-engine-setup/ovirt-engine/db/schema.py", line 437, in _validation
    self._checkSnapshotCompatibilityVersion()
  File "/usr/share/ovirt-engine/setup/bin/../plugins/ovirt-engine-setup/ovirt-engine/db/schema.py", line 212, in _checkSnapshotCompatibilityVersion
    'v': snapshot_cl,
UnboundLocalError: local variable 'snapshot_cl' referenced before assignment
2019-07-30 14:24:31,118+0000 ERROR otopi.context context._executeMethod:154 Failed to execute stage 'Setup validation': local variable 'snapshot_cl' referenced before assignment


After some debugging, I have found the problem is in the xml namespace in the ovf of the snapshots.
The snapshot uses namespace: xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1", but the code expects "http://schemas.dmtf.org/ovf/envelope/1/".


The ovf namespace was changed in patch: https://gerrit.ovirt.org/#/c/84802/



Version-Release number of selected component (if applicable):
ovirt-engine-setup 4.3.5.4-1.el7
ovirt-engine.noarch 4.3.2.1-1.el7

Comment 1 Yedidyah Bar David 2019-07-31 09:11:14 UTC
I think that a workaround can be, no idea about implications:

update snapshots set vm_configuration=REPLACE(vm_configuration, 'http://schemas.dmtf.org/ovf/envelope/1', 'http://schemas.dmtf.org/ovf/envelope/1/')

Comment 2 Yedidyah Bar David 2019-08-19 06:10:05 UTC
QE: To reproduce/verify:

1. Install and setup older engine. I think 4.2 will reproduce, you can/should also try 4.1.
2. Create there storage, add a host, create a vm, create a snapshot on the vm.
3. If you started with 4.1, upgrade to 4.2.
4. Upgrade setup packages to 4.3 and run engine-setup.

If you upgraded to 4.3 < 4.3.5, you should be ok.

If you upgraded to 4.3.5 < 4.3.5.5, it would fail.

If you upgraded to 4.3.5.5, you should be ok.

No need to finish setup - you can run it until the preview and reply 'Cancel', then upgrade setup packages to your next attempted version and try again.

Comment 4 Guilherme Santos 2019-08-21 12:41:48 UTC
Verified on ovirt-engine-4.3.5.5-0.1.el7.noarch

Comment 10 errata-xmlrpc 2019-08-26 09:59:14 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2019:2561

Comment 11 Daniel Gur 2019-08-28 13:13:39 UTC
sync2jira

Comment 12 Daniel Gur 2019-08-28 13:17:53 UTC
sync2jira

Comment 13 Yedidyah Bar David 2019-09-25 06:58:56 UTC
Only now took the time to look at an actual production engine with many snapshots, some rather old. It seems like all snapshots created at <= 3.5 are shown by engine-setup as UnknownDate/UnknownLevel. I guess it's probably not that hard to parse the data also from these times, but it's probably not worth it.