Bug 1592281

Summary: virt-who checkin fails with undefined method `[]' for nil:NilClass (NoMethodError)
Product: Red Hat Satellite Reporter: Jitendra Yejare <jyejare>
Component: CandlepinAssignee: Jitendra Yejare <jyejare>
Status: CLOSED ERRATA QA Contact: Jitendra Yejare <jyejare>
Severity: urgent Docs Contact:
Priority: high    
Version: 6.4CC: ajambhul, bcourt, cwelton, ehelms, gpayelka, hsun, jsherril, jyejare, khowell, mlele, pcreech, rplevka, sghai, shyan, yuefliu
Target Milestone: 6.4.0Keywords: PrioBumpQA, Regression, Reopened, Triaged
Target Release: Unused   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: candlepin-2.4.4-1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1598850 1598851 (view as bug list) Environment:
Last Closed: 2019-01-09 21:10:46 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: 1598850, 1598851    
Bug Blocks: 1220620, 1575056, 1596343    
Attachments:
Description Flags
Virt-who Json file mentioned in Description of bug none

Description Jitendra Yejare 2018-06-18 10:35:48 UTC
Description of problem:
The virt-who json file is not being posted to satellite for creating virt-who hosts. The satellite returns '{"displayMessage":"undefined method `[]' for nil:NilClass","errors":["undefined method `[]' for nil:NilClass"]}'.

Version-Release number of selected component (if applicable):
satellite-6.4.0-9.beta.el7sat.noarch

How reproducible:
Always

Steps to Reproduce:
1. Create a json file containing host details to upload to satellite as virt-who hosts. (I attached my json file)
2. Send API call to satellite to upload the data in this json file.
# curl -k -X POST --cert /etc/pki/consumer/cert.pem --key /etc/pki/consumer/key.pem https://$SATHOST/rhsm/hypervisors -H "Content-Type: application/json" -d @"/tmp/temp.json"

Actual results:
The satelite is returning '{"displayMessage":"undefined method `[]' for nil:NilClass","errors":["undefined method `[]' for nil:NilClass"]}'.

Expected results:
Successfully created virt-who hosts as per json data.

Additional info:

Comment 2 Jitendra Yejare 2018-06-18 10:48:21 UTC
Created attachment 1452586 [details]
Virt-who Json file mentioned in Description of bug

Comment 5 Jitendra Yejare 2018-06-19 13:17:15 UTC
Yes, A regression.

Comment 6 Justin Sherrill 2018-07-05 16:35:34 UTC
*** Bug 1598488 has been marked as a duplicate of this bug. ***

Comment 7 Justin Sherrill 2018-07-05 16:38:04 UTC
2018-07-05T15:28:06 [E|bac|4cd3d] undefined method `[]' for nil:NilClass (NoMethodError)
 | /home/vagrant/git/katello/app/lib/actions/katello/host/hypervisors.rb:29:in `block (2 levels) in parse_hypervisors'
 | /home/vagrant/git/katello/app/lib/actions/katello/host/hypervisors.rb:25:in `map'
 | /home/vagrant/git/katello/app/lib/actions/katello/host/hypervisors.rb:25:in `block in parse_hypervisors'
 | /home/vagrant/git/katello/app/lib/actions/katello/host/hypervisors.rb:23:in `each'
 | /home/vagrant/git/katello/app/lib/actions/katello/host/hypervisors.rb:23:in `parse_hypervisors'




candlepin changed the results from the hypervisor checkin to only include uuids for the 'unchanged' set of hypervisors results.  This results in katello not being able to properly process the results and create the hypervisors in our db.  

Candlepin will need to either revert some or all of that change, or katello will need to fetch all hypervisors from candlepin after each checkin, potentially increasing the checkin time.

Comment 8 Justin Sherrill 2018-07-05 17:44:00 UTC
Would it be possible to revert part of this change?  Katello needs the following pieces from a hypervisor:

'name'
'uuid'
'owner' -> 'key'

Comment 9 Kevin Howell 2018-07-06 15:28:27 UTC
Not clean to revert...

Changing component to candlepin. Dev, we need to address both sync and async responses in this. Given that we already have the name, uuid, and key while building the response, we'll make a DTO for this.

Comment 10 Justin Sherrill 2018-07-06 15:30:19 UTC
We will need to test both async and sync checkins.  

Newest virt-who should do async by default, to test sync, run with:

VIRTWHO_DISABLE_ASYNC=true

Comment 12 Roman Plevka 2018-07-25 11:36:15 UTC
*** Bug 1608317 has been marked as a duplicate of this bug. ***

Comment 14 Jitendra Yejare 2018-07-30 11:20:43 UTC
Verified!

@ Satellite 6.4 snap 14

Steps:

Ditto as per description.

Observations:

1. The virt-who hosts are being created on satellite as per json data.
2. Description like error is not observed.

Comment 15 Jitendra Yejare 2018-07-30 11:21:31 UTC
Verified on:

# rpm -qa | grep candlepin
candlepin-2.4.4-1.el7.noarch
candlepin-selinux-2.4.4-1.el7.noarch

Comment 16 Bryan Kearney 2018-10-16 18:54:17 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/RHSA-2018:2927

Comment 17 Mihir Lele 2019-01-09 11:48:15 UTC
Hello,

I am re-opening this bug because I have a customer who is facing this issue after upgrading to 6.4

logs:

==> /var/log/foreman/production.log <==
2019-01-09T11:28:39 [I|app|] Started POST "/rhsm/hypervisors/ACME?reporter_id=[FILTERED]&cloaked=False&env=Library" for 1.2.3.4 at XXXX-01-09 XX:XX:XX +0000
2019-01-09T11:28:39 [I|app|d2d11] Processing by Katello::Api::Rhsm::CandlepinProxiesController#async_hypervisors_update as JSON
2019-01-09T11:28:39 [I|app|d2d11]   Parameters: {"reporter_id"=>"[FILTERED]", "cloaked"=>"False", "env"=>"Library", "owner"=>"ADMIN"}
2019-01-09T11:28:39 [I|app|d2d11] Current user: foreman_admin (administrator)
2019-01-09T11:28:39 [I|kat|d2d11] Authorized user admin(Admin User)
2019-01-09T11:28:39 [I|app|d2d11] Current user: admin (administrator)
2019-01-09T11:28:39 [I|app|d2d11] Current user: foreman_admin (administrator)
2019-01-09T11:28:39 [I|app|d2d11] Current user: admin (administrator)
2019-01-09T11:28:39 [I|app|d2d11] Completed 200 OK in 216ms (Views: 0.6ms | ActiveRecord: 23.8ms)
2019-01-09T11:28:40 [W|bac|d2d11] Polling failed, attempt no. 1, retrying in 0.5
2019-01-09T11:28:40 [W|bac|d2d11] undefined method `[]' for nil:NilClass (NoMethodError)

Comment 20 Justin Sherrill 2019-01-09 12:54:31 UTC
Mihir, 

we're going to need more details around this.  Can you find a traceback under monitor > Tasks > hypervisor update?  Any traceback in production.log when the error occurs?

A foreman-debug might help