Bug 1668720

Summary: [RHV][REST api] Cluster href had changed in RHV-4.3 - It fails for some RHV-4.3 environments the CFME refresh.
Product: Red Hat Enterprise Virtualization Manager Reporter: Angelina Vasileva <anikifor>
Component: ovirt-engineAssignee: Ori Liel <oliel>
Status: CLOSED ERRATA QA Contact: Angelina Vasileva <anikifor>
Severity: high Docs Contact:
Priority: high    
Version: 4.3.1CC: agrare, anikifor, dagur, dmetzger, istein, jfrey, jhardy, lavenel, lsvaty, masayag, mperina, obarenbo, pkliczew, Rhev-m-bugs, sborella
Target Milestone: ovirt-4.3.3-1Keywords: PrioBumpPM, Regression, TestBlocker
Target Release: 4.3.0   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: ovirt-engine-4.3.3.1 Doc Type: If docs needed, set a value
Doc Text:
This release ensures the process to provision of a virtual machine from a template completes correctly.
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-05-08 12:39:10 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: Bug
oVirt Team: Infra RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: RHEVM Target Upstream Version:
Embargoed:
Attachments:
Description Flags
evm.log none

Description Angelina Vasileva 2019-01-23 12:13:54 UTC
Created attachment 1522633 [details]
evm.log

Description of problem:
Provisioning VM from a template doesn't work for RHV 4.3

Version-Release number of selected component (if applicable):
CFME 5.10.0.32.20190115185124_c957ada
RHV 4.3.0-0.8.rc2.el7

How reproducible:
Always

Steps to Reproduce:
1. Add RHV provider
2. Go to VMs
3. Lifecycle -> Provision VMs
4. Select a template, click Continue

Actual results:
Unexpected error encountered
undefined method `uid_ems' for nil:NilClass [miq_request/prov_edit]

Expected results:
Provisioning dialog is opened

Additional info:
When provisioning the VM from the same template directly in RHV, it works. Afterwards, I'm able to see this VM in CFME.
Also, when selecting the template, CFME shows incorrect info (it shows CPUs 0, Memory 0 for this template).

There are some refresh errors, see the attached logs.

Comment 4 Piotr Kliczewski 2019-02-08 13:54:15 UTC
Here is part of the log:

[----] E, [2019-01-23T05:39:26.612639 #64944:114cf5c] ERROR -- : MIQ(ManageIQ::Providers::Redhat::InfraManager::Refresh::Strategies::Api4#refresh) EMS: [rhv_43], id: [1] Refresh failed
[----] E, [2019-01-23T05:39:26.614213 #64944:114cf5c] ERROR -- : [NoMethodError]: undefined method `ems_ref' for nil:NilClass  Method:[block (2 levels) in <class:LogProxy>]
[----] E, [2019-01-23T05:39:26.614305 #64944:114cf5c] ERROR -- : /opt/rh/cfme-gemset/bundler/gems/cfme-providers-ovirt-fe67891d889e/app/models/manageiq/providers/redhat/inventory/persister/definitions/infra_group/vms_dependency_collections.rb:63:in `block (2 levels) in ems_folder_children_custom_save_block'
/opt/rh/cfme-gemset/bundler/gems/cfme-providers-ovirt-fe67891d889e/app/models/manageiq/providers/redhat/inventory/persister/definitions/infra_group/vms_dependency_collections.rb:63:in `each'
/opt/rh/cfme-gemset/bundler/gems/cfme-providers-ovirt-fe67891d889e/app/models/manageiq/providers/redhat/inventory/persister/definitions/infra_group/vms_dependency_collections.rb:63:in `each_with_object'
/opt/rh/cfme-gemset/bundler/gems/cfme-providers-ovirt-fe67891d889e/app/models/manageiq/providers/redhat/inventory/persister/definitions/infra_group/vms_dependency_collections.rb:63:in `block in ems_folder_children_custom_save_block'
/opt/rh/cfme-gemset/gems/inventory_refresh-0.1.2/lib/inventory_refresh/save_collection/base.rb:22:in `save_inventory_object_inventory'

Comment 5 Moti Asayag 2019-02-10 11:33:33 UTC
(In reply to Piotr Kliczewski from comment #4)
> Here is part of the log:
> 
> [----] E, [2019-01-23T05:39:26.612639 #64944:114cf5c] ERROR -- :
> MIQ(ManageIQ::Providers::Redhat::InfraManager::Refresh::Strategies::
> Api4#refresh) EMS: [rhv_43], id: [1] Refresh failed
> [----] E, [2019-01-23T05:39:26.614213 #64944:114cf5c] ERROR -- :
> [NoMethodError]: undefined method `ems_ref' for nil:NilClass  Method:[block
> (2 levels) in <class:LogProxy>]
> [----] E, [2019-01-23T05:39:26.614305 #64944:114cf5c] ERROR -- :
> /opt/rh/cfme-gemset/bundler/gems/cfme-providers-ovirt-fe67891d889e/app/
> models/manageiq/providers/redhat/inventory/persister/definitions/infra_group/
> vms_dependency_collections.rb:63:in `block (2 levels) in
> ems_folder_children_custom_save_block'
> /opt/rh/cfme-gemset/bundler/gems/cfme-providers-ovirt-fe67891d889e/app/
> models/manageiq/providers/redhat/inventory/persister/definitions/infra_group/
> vms_dependency_collections.rb:63:in `each'
> /opt/rh/cfme-gemset/bundler/gems/cfme-providers-ovirt-fe67891d889e/app/
> models/manageiq/providers/redhat/inventory/persister/definitions/infra_group/
> vms_dependency_collections.rb:63:in `each_with_object'
> /opt/rh/cfme-gemset/bundler/gems/cfme-providers-ovirt-fe67891d889e/app/
> models/manageiq/providers/redhat/inventory/persister/definitions/infra_group/
> vms_dependency_collections.rb:63:in `block in
> ems_folder_children_custom_save_block'
> /opt/rh/cfme-gemset/gems/inventory_refresh-0.1.2/lib/inventory_refresh/
> save_collection/base.rb:22:in `save_inventory_object_inventory'

This reproduces also to me on development setup. The cluster-id is no longer saved for VMs or templates during the refresh.

Comment 6 Ilanit Stein 2019-02-26 15:13:33 UTC
*** Bug 1683285 has been marked as a duplicate of this bug. ***

Comment 7 Adam Grare 2019-02-26 15:23:13 UTC
It looks like the format of the cluster href is different than what we see from the vm:

ManageIQ::Providers::Redhat::InfraManager.make_ems_ref(cluster.href)
"/api/datacenters/95f329c1-3361-420a-b04e-d4c81a84adda/clusters/1b842295-6812-4cd7-87c3-dd268b9bf5f9"

ManageIQ::Providers::Redhat::InfraManager.make_ems_ref(vm.cluster.href)
"/api/clusters/1b842295-6812-4cd7-87c3-dd268b9bf5f9"

Comment 8 Adam Grare 2019-02-26 15:29:56 UTC
https://github.com/ManageIQ/manageiq-providers-ovirt/pull/343

^ Fixes the exception but doesn't fix the fact that the VMs don't have an ems_cluster due to the format of the ID changing.

Comment 10 Ilanit Stein 2019-02-27 11:35:13 UTC
I checked several RHV-4.3 (with & without OVN), that are not Hosted Engine - and these DO NOT have the refresh failure.
Seems the problem is specific to RHV-4.3 Hosted-Engine configuration.

Comment 11 Adam Grare 2019-02-28 16:44:34 UTC
Okay I updated https://github.com/ManageIQ/manageiq-providers-ovirt/pull/343 to reference clusters by id instead of href from vms and hosts.

Comment 12 Ilanit Stein 2019-03-04 08:52:02 UTC
We have a fix for this already on RHV side:

oliel explains on the change in cluster href seen in RHV-4.3, compared to RHV-4.2, 
and the RHV fix he added, in order to return it back to as it was in RHV-4.2:

Get all clusters under root: 
      http://localhost:8080/ovirt-engine/api/clusters

Get one specific cluster under root: 
      http://localhost:8080/ovirt-engine/api/clusters/xxx

Get all clusters under datacenters:
      http://localhost:8080/ovirt-engine/api/datacenters/yyy/clusters

Those all return the cluster with an href directing to the cluster under the api root:  <cluster href=".../api/clusters/xxx>

However this one: 

Get one specific cluster under datacenters:
      http://localhost:8080/ovirt-engine/api/datacenters/yyy/clusters/xxx 

Returns the cluster with an href directing to the cluster under the datacenter:  <cluster href=".../api/datacenters/yyy/clusters/xxx>


I've posted a (RHV) patch making this last one direct to the cluster under the API root as well: 
   https://gerrit.ovirt.org/#/c/98201/

Comment 13 Ilanit Stein 2019-03-04 11:42:22 UTC
*** Bug 1680521 has been marked as a duplicate of this bug. ***

Comment 14 Ilanit Stein 2019-03-04 14:15:32 UTC
changed bug component to RHV as this issue is caused by a change done on RHV-4.3

Comment 22 Angelina Vasileva 2019-03-07 09:31:02 UTC
Fixed and verified for
CFME 5.10.1.2.20190219165527_7a4a22b
RHV 4.3.2-0.1.el7

Comment 23 Ilanit Stein 2019-03-25 21:16:12 UTC
Moving bug to assigned since for Hosted Engine RHV-4.3.2, cluster href is still from shape:
/ovirt-engine/api/datacenters/xxx/clusters/yyy
and this fails the RHV refresh in CFME.

Comment 25 Ilanit Stein 2019-03-26 14:33:23 UTC
Ondra's fix verified:

I installed the ovirt-engine-restapi rpm built with Ondra's fix, on my engine.
and now Links under /api/clusters:
no longer have such path:  /ovirt-engine/api/datacenters/<id>/clusters/<id>
but rather: /ovirt-engine/api/clusters/<id>
as it was on RHV-4.2.
For all the clusters in my RHV-4.3.

Comment 27 Angelina Vasileva 2019-04-18 11:20:16 UTC
Moving to verified as is works for my HE as well as for Ilanit's.

My versions:
CFME 5.10.3.3.20190415203225_deb61ff
RHV 4.3.3.3-0.1.el7

Comment 29 errata-xmlrpc 2019-05-08 12:39:10 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/RHEA-2019:1085