Bug 1487265

Summary: Hammer composite content-view create/update with component-ids add only the first component of the list
Product: Red Hat Satellite Reporter: Djebran Lezzoum <dlezzoum>
Component: Content ViewsAssignee: Andrew Kofink <akofink>
Status: CLOSED ERRATA QA Contact: Nikhil Kathole <nkathole>
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.3.0CC: akofink, bbuckingham, ehelms, nkathole
Target Milestone: UnspecifiedKeywords: Regression, 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: Environment:
Last Closed: 2018-02-21 16:32:42 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 Djebran Lezzoum 2017-08-31 14:01:57 UTC
Created attachment 1320606 [details]
foreman-debug output

Description of problem:
Hammer composite content-view create/update with component-ids add only the first component of the list


Version-Release number of selected component (if applicable):
* candlepin-2.0.40-1.el7.noarch
* candlepin-selinux-2.0.40-1.el7.noarch
* foreman-1.15.3-2.el7sat.noarch
* foreman-cli-1.15.3-2.el7sat.noarch
* foreman-compute-1.15.3-2.el7sat.noarch
* foreman-debug-1.15.3-2.el7sat.noarch
* foreman-discovery-image-3.1.1-22.el7sat.noarch
* foreman-ec2-1.15.3-2.el7sat.noarch
* foreman-gce-1.15.3-2.el7sat.noarch
* foreman-installer-1.15.2-1.el7sat.noarch
* foreman-installer-katello-3.4.4-1.el7sat.noarch
* foreman-libvirt-1.15.3-2.el7sat.noarch
* foreman-openstack-1.15.3-2.el7sat.noarch
* foreman-ovirt-1.15.3-2.el7sat.noarch
* foreman-postgresql-1.15.3-2.el7sat.noarch
* foreman-proxy-1.15.3-1.el7sat.noarch
* foreman-rackspace-1.15.3-2.el7sat.noarch
* foreman-selinux-1.15.3-1.el7sat.noarch
* foreman-vmware-1.15.3-2.el7sat.noarch
* katello-3.4.4-2.el7sat.noarch
* katello-ca-consumer-sat-r220-02.lab.eng.rdu2.redhat.com-1.0-4.noarch
* katello-certs-tools-2.4.0-1.el7sat.noarch
* katello-client-bootstrap-1.4.0-1.el7sat.noarch
* katello-common-3.4.4-2.el7sat.noarch
* katello-debug-3.4.4-2.el7sat.noarch
* katello-default-ca-1.0-1.noarch
* katello-installer-base-3.4.4-1.el7sat.noarch
* katello-selinux-3.0.2-1.el7sat.noarch
* katello-server-ca-1.0-1.noarch
* katello-service-3.4.4-2.el7sat.noarch
* openldap-2.4.44-5.el7.x86_64
* pulp-client-1.0-1.noarch
* pulp-docker-plugins-2.4.0-2.el7sat.noarch
* pulp-katello-1.0.2-1.el7sat.noarch
* pulp-ostree-plugins-1.2.1-3.el7sat.noarch
* pulp-puppet-plugins-2.13.3-1.el7sat.noarch
* pulp-puppet-tools-2.13.3-1.el7sat.noarch
* pulp-rpm-plugins-2.13.3-1.el7sat.noarch
* pulp-selinux-2.13.3-1.el7sat.noarch
* pulp-server-2.13.3-1.el7sat.noarch
* python-ldap-2.4.15-2.el7.x86_64
* sssd-ldap-1.15.2-50.el7.x86_64
* tfm-rubygem-ldap_fluff-0.4.6-1.el7sat.noarch
* tfm-rubygem-net-ldap-0.15.0-1.el7sat.noarch


How reproducible:
Always

Steps to Reproduce:
1. Create one content view and publish it twice (we have two versions)
>>> hammer content-view info --id="405"
<<<
ID:                     405
Name:                   AMJMtoJpwf
Label:                  AMJMtoJpwf
Composite:              false
Description:            
Content Host Count:     0
Organization:           Hqf4UN
Yum Repositories:       

Docker Repositories:    

OSTree Repositories:    

Puppet Modules:         

Lifecycle Environments: 
 1) ID:   387
    Name: Library
Versions:               
 1) ID:        382
    Version:   1.0
    Published: 2017/08/31 13:25:41
 2) ID:        383
    Version:   2.0
    Published: 2017/08/31 13:25:48
Components:             

2. Create a composite content view with the content view versions as components
>>>hammer --output=csv content-view create --composite --organization-id="405" --name="fZbfxrFecp" --component-ids="382,383"
<<<
Message,Id,Name
Content view created,406,fZbfxrFecp 

3. Get the composite content view info
>>>hammer -v -u admin -p changeme  content-view info --id="406"

Actual results:
<<<
ID:                     406
Name:                   fZbfxrFecp
Label:                  fZbfxrFecp
Composite:              true
Description:            
Content Host Count:     0
Organization:           Hqf4UN
Yum Repositories:       

Docker Repositories:    

OSTree Repositories:    

Puppet Modules:         

Lifecycle Environments: 

Versions:               

Components:             
 1) ID:   382
    Name: AMJMtoJpwf 1.0
Activation Keys:


Expected results:
component with id 383 also listed in composite content view components

Additional info:
the update command has the same effect as create when creating the composite content view without component-ids and after update it with the component-ids only the first element is added.

if we reverse the ids so that 383 is the first:
>>>hammer content-view create --composite --organization-id="405" --name="fZbfxrFecp" --component-ids="383,382"
only the component 383 will be listed

does not mater how much elements (tested with tree components) always only the first one is added


Note: 
 1- This is a working automation test that is working on 6.2
 2- If this scenario is not acceptable any more an error should be displayed and not silently adding the first one
 3- If the component versions are from different content views the two components are added and shown as expected

Comment 2 Brad Buckingham 2017-09-14 12:46:13 UTC
The behavior described by this bz may have been introduced by https://github.com/Katello/katello/pull/6416.

The behavior observed in 6.2 was incorrect.  A composite content view should not have 2 versions of the same component view.  That said, I agree with note 2 in the description and that Satellite should generate an error to the user.

Comment 3 Brad Buckingham 2017-09-19 09:15:32 UTC
Created redmine issue http://projects.theforeman.org/issues/20995 from this bug

Comment 4 Satellite Program 2017-09-25 18:09:57 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/20995 has been resolved.

Comment 5 Nikhil Kathole 2017-10-09 12:54:47 UTC
VERIFIED

Version Tested:
Satellite-6.3 Snap 19

steps:

# hammer content-view info --id=6
ID:                     6
Name:                   test_view
Label:                  test_view
Composite:              false
Description:
Content Host Count:     0
Organization:           Default Organization
Yum Repositories:
 1) ID:    5
    Name:  sat6tool6
    Label: sat6tool6
Docker Repositories:

OSTree Repositories:

Puppet Modules:

Lifecycle Environments:
 1) ID:   2
    Name: DEV
 2) ID:   1
    Name: Library
Versions:
 1) ID:        7
    Version:   1.0
    Published: 2017/10/09 12:02:37
 2) ID:        8
    Version:   2.0
    Published: 2017/10/09 12:03:50
Components:

Activation Keys:

# hammer --output=csv content-view create --composite --organization-id="1" --name="compositeCV" --component-ids="7,8"
Could not create the content view:
  Validation failed: Content view components is invalid, Content view components is invalid

As per comment #2 and note 2, Satellite generate an error to the user as above.
But found another issue that UI shows another versions to add after adding same component view's version in composite content view.Here is the bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=1499826

Comment 6 Bryan Kearney 2018-02-21 16:32:42 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