Bug 1478420

Summary: [Satellite 6] in foreman db hosts table, lifecycle_environment_id and content_view_id are not updated.
Product: Red Hat Satellite Reporter: Stefan Nemeth <snemeth>
Component: Hosts - ContentAssignee: Brad Buckingham <bbuckingham>
Status: CLOSED ERRATA QA Contact: Nikhil Kathole <nkathole>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.2.10CC: bbuckingham, inecas, jcallaha, nkathole
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: tfm-rubygem-katello-3.4.5 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-02-21 16:51:07 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 Stefan Nemeth 2017-08-04 14:11:01 UTC
Description of problem:
When host gets assigned different lifecycle environment or content view, via hammer or webui, values in hosts table of foreman db are not updated. 

Values gets updated properly in cp_pool and in katello_systems, but than there are different values for tested host in hosts and katello_systems and cp_pool (in candlepin db) tables 

Version-Release number of selected component (if applicable):
6.2.10

How reproducible:
100%

Steps to Reproduce:
1. provision a host
2. check values in foreman database 
foreman=# select content_view_id,lifecycle_environment_id from hosts where name='snemeth-hosttable-test.sysmgmt.lan';
-[ RECORD 1 ]------------+--
content_view_id          | 1
lifecycle_environment_id | 1

3.change lifecycle environment and content view in webui or using hammer

4. verify hosts table entry in db.

Actual results:

hosts table not updated 

katello_systems and cp_pool updated as expected.
Expected results:
update hosts table as well.

Additional info:

Comment 2 Brad Buckingham 2017-08-14 12:29:19 UTC
Created redmine issue http://projects.theforeman.org/issues/20581 from this bug

Comment 3 Satellite Program 2017-09-01 18:19:06 UTC
Upstream bug assigned to bbuckingham

Comment 4 Brad Buckingham 2017-09-07 14:58:09 UTC
This appears to be working properly on internal Satellite 6.3 SNAP 14 : satellite-6.3.0-17.0.beta.el7sat.noarch, tfm-rubygem-katello-3.4.5-1.el7sat.noarch

For a content host, changed the lifecycle environment and content view several times using the UI and in each case, it was updated correctly in the database.

With satellite 6.3, the database table and attributes to monitor are:
select content_view_id,lifecycle_environment_id from katello_content_facets;


Moving the bugzilla forward for inclusion in next round of ON_QA.

Comment 5 Nikhil Kathole 2017-09-10 10:50:53 UTC
VERIFIED

Version Tested:
Satellite-6.3 Snap 15

# rpm -qa| grep tfm-rubygem-katello
tfm-rubygem-katello_ostree-3.4.5.1-1.el7sat.noarch
tfm-rubygem-katello-3.4.5.1-1.el7sat.noarch

steps:

# hammer lifecycle-environment list
---|---------|--------
ID | NAME    | PRIOR
---|---------|--------
2  | DEV     | Library
1  | Library |
4  | PROD    | QE
3  | QE      | DEV
---|---------|--------

# hammer content-view list
----------------|---------------------------|---------------------------|-----------|---------------------|---------------
CONTENT VIEW ID | NAME                      | LABEL                     | COMPOSITE | LAST PUBLISHED      | REPOSITORY IDS
----------------|---------------------------|---------------------------|-----------|---------------------|---------------
4               | Capsule RHEL 7 CV         | Capsule_RHEL_7_CV         |           | 2017/09/10 07:58:21 | 6, 3, 7
1               | Default Organization View | Default_Organization_View |           | 2017/09/10 06:11:00 |
3               | RHEL 6 CV                 | RHEL_6_CV                 |           | 2017/09/10 07:46:36 | 2, 4, 5
2               | RHEL 7 CV                 | RHEL_7_CV                 |           | 2017/09/10 07:39:35 | 6, 1, 3
----------------|---------------------------|---------------------------|-----------|---------------------|------------

# hammer host info --id 2 | grep "Lifecycle Environment\|Content View"
    Content View:          RHEL 7 CV
    Lifecycle Environment: DEV

foreman=# select content_view_id,lifecycle_environment_id from katello_content_facets;
 content_view_id | lifecycle_environment_id
-----------------+--------------------------
               2 |                        2
(1 row)


# hammer host update --id=2 --content-view="RHEL 6 CV"
Host updated

foreman=# select content_view_id,lifecycle_environment_id from katello_content_facets;
 content_view_id | lifecycle_environment_id
-----------------+--------------------------
               3 |                        2
(1 row)

# hammer host update --id=2 --lifecycle-environment="QE"
Host updated

foreman=# select content_view_id,lifecycle_environment_id from katello_content_facets;
 content_view_id | lifecycle_environment_id
-----------------+--------------------------
               3 |                        3

# hammer host update --id=2 --lifecycle-environment="DEV" --content-view="RHEL 7 CV"
Host updated

foreman=# select content_view_id,lifecycle_environment_id from katello_content_facets;
 content_view_id | lifecycle_environment_id
-----------------+--------------------------
               2 |                        2
(1 row)

Successfully updates entries in database.

Comment 6 Satellite Program 2018-02-21 16:51:07 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:0336