Bug 1325124 - hammer import activation-key fails to create composite CVs
Summary: hammer import activation-key fails to create composite CVs
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Uncategorized
Version: 6.2.0
Hardware: Unspecified
OS: Unspecified
unspecified
high vote
Target Milestone: Unspecified
Assignee: Tom McKay
QA Contact: Lukas Pramuk
URL: http://projects.theforeman.org/issues...
Whiteboard:
Depends On: 1337746
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-04-08 10:51 UTC by Lukas Pramuk
Modified: 2019-09-26 14:47 UTC (History)
5 users (show)

Fixed In Version: rubygem-hammer_cli_import-0.11.0-1
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-07-27 11:06:09 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Foreman Issue Tracker 14614 None None None 2016-04-22 16:50:01 UTC

Description Lukas Pramuk 2016-04-08 10:51:24 UTC
Description of problem:
hammer import activation-key fails to create composite CVs. Import activation-key used to use imported CVs and create composite CV out of them (=grouping base and child channel based CVs togheter).
But CV import was broken for sometime so that broken ability to create a composite CV during AK import cannot be simply revealed till now as BZ #1316110 has been fixed. 

Version-Release number of selected component (if applicable):
@Sat6.2.0-Beta-Snap6.2
tfm-rubygem-hammer_cli_import-0.10.23-1.el6sat.noarch

How reproducible:
always

Steps to Reproduce:
0. Import a organization and upload manifest (manually)

1. Run import repository-enable for RH repositories (manually) and sync 'em (rhel-x86_64-server-7 + rhn-tools-rhel-x86_64-server-7)

2. Prepare csv file for AK import
# cat activation-keys.csv
org_id,token,note,usage_limit,is_disabled,deploys_configs,entitlement,channel_label,base_channel_id,child_channel_id,cfg_channel_pos,server_group,server_group_id,package_name
1,1-key,None,,0,N,enterprise_entitled;monitoring_entitled;provisioning_entitled,rhel-x86_64-server-7;rhn-tools-rhel-x86_64-server-7,103;None,None;106,config-1|1,,,

3. Run AK import
# hammer import activation-key --verbose --csv-file activation-keys.csv
Importing from activation-keys.csv
Creating new activation key: 1-key
Creating new ak content view: ak_1
Caught RestClient::InternalServerError:500 Internal Server Error while processing activation key 1
Summary
  Created 1 activation_key.

Actual results:
500 ISE, composite CV not created

Expected results:
composite CV successfully created

Additional info:
the error message is the same as with BZ #1316110 - undefined method `composite?' for nil:NilClass

Comment 1 Lukas Pramuk 2016-04-08 10:57:16 UTC
With successive runs you can hit it still:

# hammer import activation-key --verbose --csv-file activation-keys.csv
Importing from /tmp/exports/activation-keys.csv
Activation key [1-key->1] already imported.
Creating new ak content view: ak_1
Caught RestClient::InternalServerError:500 Internal Server Error while processing activation key 1
Summary
  Found 1 activation_key.
  No action taken.

hammer -d show us more:

[ INFO 2016-04-08 12:38:15 API] POST /katello/api/organizations/4/content_views
[DEBUG 2016-04-08 12:38:15 API] Params: {
             :name => "ak_1",
            :label => "ak_1",
        :composite => true,
      :description => "Composite content view for activation key 1-key",
    :component_ids => [
        [0] 19,
        [1] 37
    ]
}
[DEBUG 2016-04-08 12:38:15 API] Headers: {}
[DEBUG 2016-04-08 12:38:15 API] 500 Internal Server Error
{
    "displayMessage" => "undefined method `composite?' for nil:NilClass",
            "errors" => [
        [0] "undefined method `composite?' for nil:NilClass"
    ]
}
Caught RestClient::InternalServerError:500 Internal Server Error while processing activation key 1
Summary
  Found 1 activation_key.
  No action taken.

Comment 3 Lukas Pramuk 2016-04-08 12:10:00 UTC
More descriptive reproducer:

1. # cat users.csv 
organization_id,organization,user_id,username,last_name,first_name,position,email,role,creation_time,last_login_time,active
1,SatelliteQE,1,admin,Admin,Admin,,root@localhost,Satellite Administrator,2014-09-10 19:39:59,2016-04-07 01:00:14,enabled

2. # hammer import organization --verbose --csv-file users.csv 
Importing from users.csv
Creating new organization: SatelliteQE
Summary
  Created 1 organization.

3. # hammer subscription upload --organization SatelliteQE --file manifest.zip 
[...................................................................................................................................................] [100%]

4. # cat channels.csv 
channel_id,channel_label,channel_name,number_of_packages,org_id
103,rhel-x86_64-server-7,Red Hat Enterprise Linux Server (v. 7 for 64-bit x86_64),0,
106,rhn-tools-rhel-x86_64-server-7,RHN Tools for RHEL Server (v. 7 for x86_64),25,

5. # hammer import repository-enable --verbose --csv-file channels.csv --synchronize --wait
Importing from channels.csv
Enabling /content/dist/rhel/server/7/7Server/x86_64/os/Packages for channel rhel-x86_64-server-7 in org 7
Mapping redhat repository [[1, 103]->74].
Registering tasks for uuids: ["b11f9a35-fb4a-4528-957f-20fc92303994"].
Starting thread for async tasks
Enabling /content/dist/rhel/server/7/7Server/x86_64/rhn-tools/os/Packages for channel rhn-tools-rhel-x86_64-server-7 in org 7
Mapping redhat repository [[1, 106]->75].
Registering tasks for uuids: ["9b9fb539-e6be-4932-9fe4-195156ce637d"].
Waiting for async tasks to finish
Asynchronous tasks: 0 of 2 done (~ 0.25%)
...
Condition ["b11f9a35-fb4a-4528-957f-20fc92303994"] met
Creating new redhat content view: Red Hat Enterprise Linux Server (v. 7 for 64-bit x86_64)
Asynchronous tasks: 2 of 2 done (~100.00%)
Exiting thread (exit requested, all tasks done).
Summary
  Mapped 2 redhat_repositories.
  Created 2 redhat_content_views.

6. # cat activation-keys.csv 
org_id,token,note,usage_limit,is_disabled,deploys_configs,entitlement,channel_label,base_channel_id,child_channel_id,cfg_channel_pos,server_group,server_group_id,package_name
1,1-key,None,,0,N,enterprise_entitled;monitoring_entitled;provisioning_entitled,rhel-x86_64-server-7;rhn-tools-rhel-x86_64-server-7,103;None,None;106,config-1|1,,,

7. # hammer import activation-key --verbose --csv-file activation-keys.csv
Importing from activation-keys.csv
Creating new activation key: 1-key
Creating new ak content view: ak_5
Caught RestClient::InternalServerError:500 Internal Server Error while processing activation key 5
Summary
  Created 1 activation key.

Comment 4 Tom McKay 2016-04-13 14:45:47 UTC
Created redmine issue http://projects.theforeman.org/issues/14614 from this bug

Comment 5 Bryan Kearney 2016-04-13 16:11:19 UTC
Upstream bug component is Uncategorized

Comment 6 Bryan Kearney 2016-04-13 20:11:22 UTC
Upstream bug component is Uncategorized

Comment 7 Tom McKay 2016-07-08 17:28:26 UTC
On a fresh install of Sat-6.2, can I get the full steps and Sat-5 export data? I am not able to reproduce any issues w/ activation keys but I suspect it may be due to my setup not matching. The composite content views created for me have just one CV in them.


$ hammer import activation-key --verbose --csv-file /home/thomasmckay/data/1-small/exports/activation-keys.csv
Importing from /home/thomasmckay/data/1-small/exports/activation-keys.csv
Creating new activation key: 5-key
Activation key [4-key->9] already imported.
Activation key [3-key->8] already imported.
Activation key [1-key->6] already imported.
Activation key [2-key->7] already imported.
Creating new ak content view: ak_10
  Publishing content view: 25
  Associating activation key [10] with content view [25]
Updating activation key with id: 10
  Content view ak_9 already created, reusing.
  Associating activation key [9] with content view [24]
Updating activation key with id: 9
  Content view ak_8 already created, reusing.
  Associating activation key [8] with content view [23]
Updating activation key with id: 8
  Content view ak_6 already created, reusing.
  Associating activation key [6] with content view [20]
Updating activation key with id: 6
  Content view ak_7 already created, reusing.
  Associating activation key [7] with content view [21]
Updating activation key with id: 7
Summary
  Created 1 activation key.
  Created 1 ak content view.
  Found 4 activation_keys.

Comment 8 Lukas Pramuk 2016-07-11 13:39:24 UTC
RE can I get the full steps and Sat-5 export data?

Comment #3 provides them all

Comment 9 Lukas Pramuk 2016-07-11 13:54:52 UTC
cut'n'paste friendly format :-) 

1)
cat > users.csv << EOF
organization_id,organization,user_id,username,last_name,first_name,position,email,role,creation_time,last_login_time,active
1,SatelliteQE,1,admin,Admin,Admin,,root@localhost,Satellite Administrator,2014-09-10 19:39:59,2016-04-07 01:00:14,enabled
EOF

2)
hammer import organization --verbose --csv-file users.csv

3)
hammer subscription upload --organization SatelliteQE --file manifest.zip

4)
cat > channels.csv << EOF
channel_id,channel_label,channel_name,number_of_packages,org_id
103,rhel-x86_64-server-7,Red Hat Enterprise Linux Server (v. 7 for 64-bit x86_64),0,
106,rhn-tools-rhel-x86_64-server-7,RHN Tools for RHEL Server (v. 7 for x86_64),25,
EOF

5)
hammer import repository-enable --verbose --csv-file channels.csv --synchronize --wait

6)
cat > activation-keys.csv << EOF 
org_id,token,note,usage_limit,is_disabled,deploys_configs,entitlement,channel_label,base_channel_id,child_channel_id,cfg_channel_pos,server_group,server_group_id,package_name
1,1-key,None,,0,N,enterprise_entitled;monitoring_entitled;provisioning_entitled,rhel-x86_64-server-7;rhn-tools-rhel-x86_64-server-7,103;None,None;106,config-1|1,,,
EOF

7)
hammer import activation-key --verbose --csv-file activation-keys.csv

Comment 10 Lukas Pramuk 2016-07-11 21:26:03 UTC
This bug is not hammer import specific, rather it is about that hammer generally is not able to create composite CV: 

# hammer content-view create --organization-id 3 --composite --name my_ak1 --component-ids 5,6
Could not create the content view:
  undefined method `composite?' for nil:NilClass

This needs to be fixed at model?! 
As similar BZ 1316110 (undefined method `composite?' for nil:NilClass) was surprisingly fixed that way.
See PR https://github.com/Katello/katello/pull/5927

Comment 11 Bryan Kearney 2016-07-12 12:13:08 UTC
Upstream bug component is Uncategorized

Comment 12 Mike McCune 2016-07-12 21:14:38 UTC
I filed a new bug for the content-view composite bug as that is unrelated to this bug:

https://bugzilla.redhat.com/show_bug.cgi?id=1355894

can we have this bug focus entirely on importing activation keys via hammer import?

If this is unreproducable I'd consider moving this to ON_QA for a re-test or VERIFIED if we know it works fine in SNAP19+

Comment 13 Lukas Pramuk 2016-07-13 07:40:12 UTC
It was already filed as
BZ 1337746 hammer content-view create fails when component-ids are specified

OK, once that BZ is fixed we can test if that fix helps to resolve this hammer import BZ.

Comment 14 Lukas Pramuk 2016-07-13 07:44:46 UTC
As this BZ having blocker+ is blocked by BZ 1337746 in sat-backlog we should prioritize the same way the blocking BZ.

Comment 15 Lukas Pramuk 2016-07-18 11:04:21 UTC
BZ 1337746 is VERIFIED now.
We can procceed with this one too.

Comment 16 Lukas Pramuk 2016-07-18 11:08:30 UTC
VERIFIED.

satellite-6.2.0-20.1.el7sat.noarch

# hammer import activation-key --verbose --csv-file activation-keys.csv
Importing from activation-keys.csv
Creating new activation key: 1-key
Creating new ak content view: ak_2                    <<< yay it works
  Publishing content view: 11
  Associating activation key [2] with content view [11]
Updating activation key with id: 2
Summary
  Created 1 activation key.
  Created 1 ak content view.                          <<< yay it works

Comment 17 Bryan Kearney 2016-07-27 11:06:09 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/RHBA-2016:1501


Note You need to log in before you can comment on or make changes to this bug.