Bug 1777440

Summary: 'Hypervisors' task fails with 'undefined method `[]' for nil:NilClass' error
Product: Red Hat Satellite Reporter: Jan Senkyrik <jsenkyri>
Component: CandlepinAssignee: Barnaby Court <bcourt>
Status: CLOSED NEXTRELEASE QA Contact: jcallaha
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.5.0CC: bbuckingham, hsun, jturel, pmoravec, wpoteat
Target Milestone: 6.7.0Keywords: Triaged
Target Release: Unused   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1812904 (view as bug list) Environment:
Last Closed: 2020-01-06 21:10:01 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1812904    

Description Jan Senkyrik 2019-11-27 15:30:38 UTC
Description of problem:
'Hypervisors' task fails with 'undefined method `[]' for nil:NilClass' error when 'virt-who-0.24.7-1.el7.noarch' is being used. This is not reproducible with virt-who-0.22.5-1.el7.noarch.

### TEST with 'virt-who-0.24.7-1.el7.noarch' ###

# rpm -qa | grep -e virt-who -e satellite-6
~~~
virt-who-0.24.7-1.el7.noarch
satellite-6.5.2.1-1.el7sat.noarch
~~~

- Config file:

# cat /etc/virt-who.d/02499113.conf
~~~
[02499113]
type=fake
file=/etc/virt-who.d/json/02499113.json
is_hypervisor=True
owner=Default_Organization
env=Library
hypervisor_id=hostname
rhsm_hostname=jsenkyri-sat64.sysmgmt.lan
rhsm_username=admin
rhsm_password=XXX
rhsm_prefix=/rhsm
~~~

- Mappings being used: attached '02499113.json' file

- First virt-who run ends in success:
~~~
Id: 05359f6c-5a89-4d97-9670-f7d9461cce16
Label: Actions::Katello::Host::Hypervisors
Status: stopped
Result: success
Started at: 2019-11-27 13:17:36 UTC
Ended at: 2019-11-27 13:21:57 UTC 
~~

- Second (and any future) virt-who run with the same config and same mappings ends with error:
~~~
Id: 46616c49-4709-4232-948c-e8939cd8437e
Label: Actions::Katello::Host::Hypervisors
Status: stopped
Result: warning
Started at: 2019-11-27 13:31:31 UTC
Ended at: 2019-11-27 13:31:37 UTC
~~~

~~~
NoMethodError
undefined method `[]' for nil:NilClass
~~~

____________________________


### TEST with 'virt-who-0.22.5-1.el7.noarch' ###

# rpm -qa | grep -e virt-who -e satellite-6
~~~
virt-who-0.22.5-1.el7.noarch
satellite-6.5.2.1-1.el7sat.noarch
~~~

- Config file:

# cat /etc/virt-who.d/02499113.conf
~~~
[02499113]
type=fake
file=/etc/virt-who.d/json/02499113-older-virt-who.json
is_hypervisor=True
owner=Default_Organization
env=Library
hypervisor_id=hostname
rhsm_hostname=jsenkyri-sat64.sysmgmt.lan
rhsm_username=admin
rhsm_password=XXX
rhsm_prefix=/rhsm
~~~

- Mappings being used: attached '02499113-older-virt-who.json' file

- First any any other future virt-who run ends with success:
~~~
Id: 78e7e97a-eada-410b-ad80-4f91cc700d43
Label: Actions::Katello::Host::Hypervisors
Status: stopped
Result: success
Started at: 2019-11-27 14:50:01 UTC
Ended at: 2019-11-27 14:52:09 UTC
~~~

____________________________

Additional info:
- This is happening because 'virt-who-0.24.7-1' reports duplicate 'dmi.system.uuid' for some of the hypervisors:

# grep '20202020-2020-2020-2020-202020202020' 0.24.7-1.json
~~~ 
                "dmi.system.uuid": "20202020-2020-2020-2020-202020202020", 
                "dmi.system.uuid": "20202020-2020-2020-2020-202020202020", 
                "dmi.system.uuid": "20202020-2020-2020-2020-202020202020", 
                "dmi.system.uuid": "20202020-2020-2020-2020-202020202020", 
                "dmi.system.uuid": "20202020-2020-2020-2020-202020202020", 
                "dmi.system.uuid": "20202020-2020-2020-2020-202020202020", 
~~~


- 'virt-who-0.22.5-1' doesn't do that:

# grep '20202020-2020-2020-2020-202020202020' 0.22.5-1.json
~~~
<no results>
~~~

- 'virt-who-0.24.7-1' reports "dmi.system.uuid" for every hypervisor:

# grep dmi.system.uuid 0.24.7-1.json | wc -l
~~~
831
~~~

- 'virt-who-0.22.5-1' reports "dmi.system.uuid" for only a part of them:

# grep dmi.system.uuid 0.22.5-1.json | wc -l
~~~
64
~~~

____________________________


It's clear that the root cause of this issue are the duplicate hypervisor uuids which is something that needs to be fixed on the system level (in this case those are ESX hosts). That being said can we somehow instruct virt-who to not pass 'dmi.system.uuid' to Satellite? Or is the only current workaround to just stay on the older virt-who version until the duplicate uuids are gone?

Thanks & Kind regards,
Jan