Bug 1816853

Summary: Report generated by Red Hat Inventory Uploads is empty.
Product: Red Hat Satellite Reporter: gtaylor
Component: RH Cloud - InventoryAssignee: Shimon Shtein <sshtein>
Status: CLOSED ERRATA QA Contact: Mirek Długosz <mzalewsk>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.6.0CC: jjeffers, wpinheir
Target Milestone: 6.8.0Keywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1862253 (view as bug list) Environment:
Last Closed: 2020-10-27 13:00:52 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:

Description gtaylor 2020-03-24 21:45:04 UTC
Description of problem:
The report generated on RH Inventory > Generating > Restart is lacking useful data when looking at the .json file. The finished file is located at /var/lib/foreman/red_hat_inventory/uploads/done/report_for_1.tar.gz.  Untarring this file and viewing with "cat file_name.json | json_reformat" does not show hosts.  Example to follow below.  One of the purposes of reviewing this file is for use as a troubleshooting step to determine why hosts are not showing up on the subscription watch page. 


Version-Release number of selected component (if applicable):
tfm-rubygem-foreman_inventory_upload-1.0.2-0.1.el7sat.noarch

How reproducible:
Always


Steps to Reproduce:
1. Use a manifest with content access mode as 'org_environment'.
2. As per docs, install tfm-rubygem-foreman_inventory_upload-*, restart satellite services
3. Register Content Hosts to Satellite.
4. GUI: RH Inventory > Generating > Restart
5. tar xzvf /var/lib/foreman/red_hat_inventory/uploads/done/report_for_1.tar.gz
6. cat ./46ee7f2b-072c-4dde-93e1-e0e7695e23cc.json | json_reformat 

Actual results:
hosts data structure is empty:

# cat ./46ee7f2b-072c-4dde-93e1-e0e7695e23cc.json | json_reformat 
{
    "report_slice_id": "46ee7f2b-072c-4dde-93e1-e0e7695e23cc",
    "hosts": [

    ]
}


Expected results:
host are listed as per the completion summary.  The completion summary is shown directly below with 'adding slice 46ee7f2b-072c-4dde-93e1-e0e7695e23cc with 5 hosts'. 

Additional info:

Output as seen in the GUI during the run:
~~~
Must specify either portal_user or organization_id

I, [2020-03-24T13:46:05.794173 #27819] INFO -- : Started generating hosts report in /tmp/d20200324-27819-7fwsfk

I, [2020-03-24T13:46:05.852434 #27819] INFO -- : Adding slice 46ee7f2b-072c-4dde-93e1-e0e7695e23cc with 5 hosts

I, [2020-03-24T13:46:07.431429 #27819] INFO -- : Report generation finished

I, [2020-03-24T13:46:07.431520 #27819] INFO -- : Archiving generated report

I, [2020-03-24T13:46:07.476832 #27819] INFO -- : tar: ./

./metadata.json

./46ee7f2b-072c-4dde-93e1-e0e7695e23cc.json

I, [2020-03-24T13:46:07.476940 #27819] INFO -- : Report archived successfully

Successfully generated /var/lib/foreman/red_hat_inventory/generated_reports/report_for_1.tar.gz for organization id 1
~~~


This metadata.json file from the tar file indicates 5 hosts. 
~~~
# cat metadata.json | json_reformat 
{
    "report_id": "ca6aa32c-dabc-404b-999c-137c469edd79",
    "host_inventory_api_version": "1.0",
    "source": "Satellite",
    "report_slices": {
        "46ee7f2b-072c-4dde-93e1-e0e7695e23cc": {
            "number_hosts": 5
        }
    }
}


Info on the actual Content Host:
~~~
[root@sw1 ~]# subscription-manager identity
system identity: ebb6a614-28e9-450d-82c9-5fd5d05c1c72
name: sw1
org name: acme
org ID: acme
environment name: Library
~~~

~~~
# hammer --csv host list --organization acme
Id,Name,Operating System,Host Group,IP,MAC,Global Status,Content View,Lifecycle Environment
1,subwatch.usersys.redhat.com,RedHat 7.7,,10.8.29.232,00:50:56:8d:0c:80,OK,,
2,sw1,RedHat 7.7,,10.8.30.107,00:50:56:8d:0e:1a,Warning,Default Organization View,Library
3,sw2,RedHat 7.7,,10.8.30.108,00:50:56:8d:b3:aa,Warning,Default Organization View,Library
4,virt-who-esxi1.lab.eng.rdu2.redhat.com-3,,,,,Warning,,
6,virt-who-esxi2.lab.eng.rdu2.redhat.com-3,,,,,Warning,,
5,virt-who-esxi4.lab.eng.rdu2.redhat.com-3,,,,,Warning,,
~~~

~~~
# hammer host info --name sw1 
Id:                       2
Name:                     sw1
Organization:             acme
Location:                 washington
Cert name:                sw1
Managed:                  no
Installed at:             
Last report:              
Uptime (seconds):         12563
Status:                   
    Global Status: Warning
Network:                  
    IPv4 address: 10.8.30.107
    MAC:          00:50:56:8d:0e:1a
Network interfaces:       
 1) Id:           2
    Identifier:   ens192
    Type:         interface (primary, provision)
    MAC address:  00:50:56:8d:0e:1a
    IPv4 address: 10.8.30.107
    FQDN:         sw1
Operating system:         
    Architecture:           x86_64
    Operating System:       RedHat 7.7
    Build:                  no
    Custom partition table:
Parameters:               

All parameters:           
    enable-puppet5 => true
    enable-epel => false
Additional info:          
    Owner:      Anonymous Admin
    Owner Type: User
    Enabled:    yes
    Model:      VMware Virtual Platform
    Comment:
OpenSCAP Proxy:           
Content Information:      
    Content View:          
        ID:   1
        Name: Default Organization View
    Lifecycle Environment: 
        ID:   1
        Name: Library
    Content Source:        
        ID:   
        Name:
    Kickstart Repository:  
        ID:   
        Name:
    Applicable Packages:   0
    Upgradable Packages:   0
    Applicable Errata:     
        Enhancement: 0
        Bug Fix:     0
        Security:    0
Subscription Information: 
    UUID:                          ebb6a614-28e9-450d-82c9-5fd5d05c1c72
    Last Checkin:                  2020-03-24 20:43:22 UTC
    Service Level:                 
    Release Version:               
    Autoheal:                      true
    Registered To:                 subwatch.usersys.redhat.com
    Registered At:                 2020-03-24 18:33:19 UTC
    Registered by Activation Keys: 
     1) ak-one
Host Collections:

Comment 4 Shimon Shtein 2020-03-29 13:08:45 UTC
This host was not connected to a pool:

irb(main):001:0> hh = Host.find(2)
=> #<Host::Managed id: 2, name: "sw1" ...
... Snipped ...
irb(main):003:0> hh.subscription_facet.pools
=> #<ActiveRecord::Associations::CollectionProxy []>


irb(main):005:0> Katello::Pool.all
=> #<ActiveRecord::Relation [#<Katello::Pool id: 60,
... Snipped ...


In the second statement, you can see that the host is not associated with any pool.
If you feel it should be, we should contact someone with more Katello knowledge.

Comment 10 James Jeffers 2020-08-03 14:52:06 UTC
*** Bug 1862253 has been marked as a duplicate of this bug. ***

Comment 13 errata-xmlrpc 2020-10-27 13:00:52 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 (Important: Satellite 6.8 release), 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-2020:4366