Bug 872334

Summary: existing orgs do not get default value for system_info_keys in database
Product: [Retired] Subscription Asset Manager Reporter: Adam Price <adprice>
Component: katelloAssignee: Katello Bug Bin <katello-bugs>
Status: CLOSED ERRATA QA Contact: Og Maciel <omaciel>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 1.2CC: gkhachik, jomara, omaciel, tomckay
Target Milestone: rcKeywords: Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 870456 Environment:
Last Closed: 2013-02-21 19:18:36 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: 870456    
Bug Blocks: 816564    

Description Adam Price 2012-11-01 20:03:28 UTC
+++ This bug was initially created as a clone of Bug #870456 +++

NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.each
/home/tomckay/code/katello/src/app/models/system.rb:230:in `init_default_custom_info_keys'

When registering a system against an org created prior to custom_info_keys

--- Additional comment from adprice on 2012-10-29 13:49:21 EDT ---

https://github.com/Katello/katello/commit/2617576d9d230f282bdbcb01afd932547410ab82

--- Additional comment from adprice on 2012-10-29 13:50:55 EDT ---

if you hit an error similar to this:

NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.each
/home/tomckay/code/katello/src/app/models/system.rb:230:in
`init_default_custom_info_keys'

it means you had at least one org that existed prior to default system
info keys.

run 'rake db:migrate:redo VERSION=20120924211134' on current-master to undo the
system_info_keys migration and correctly apply the new column to all
pre-existing organizations.

If any of your organizations had any data in the system_info_keys
column, unfortunately it will be removed.

Comment 2 Adam Price 2012-11-15 14:29:49 UTC
this was caused by having an organization that existed prior to the migration that added Organization's system_info_keys.

to verify:

1. Create an organization prior to the existence of system_info_keys.
2. migrate the db to add org system_info_keys
3. check to see if pre-existing org has system_info_keys = [] (should not be nil)

Comment 3 Og Maciel 2012-11-15 15:19:36 UTC
To verify this, first install 1.0 or 1.1 and create an org. Then upgrade to 1.2. The verification itself is via cli.

Comment 5 Og Maciel 2012-11-27 20:28:38 UTC
Before the update:
------------------

# headpin -u admin -p admin org info --name SAMQE
-----------------------------------------------------------------------------------------------------
                                      Organization Information
-----------------------------------------------------------------------------------------------------

Id:          2
Name:        SAMQE
Description:


After the update:
-----------------

# headpin -u admin -p admin org info --name SAMQE-----------------------------------------------------------------------------------------------------
                                      Organization Information
-----------------------------------------------------------------------------------------------------

Id                       : 2
Name                     : SAMQE
Description:
    
Available Service Levels:
    Premium
Default System Info Keys:
    [  ]

Comment 6 Og Maciel 2012-11-27 20:30:00 UTC
Verified:
* candlepin-0.7.19-1.el6_3.noarch
* candlepin-tomcat6-0.7.19-1.el6_3.noarch
* katello-candlepin-cert-key-pair-1.0-1.noarch
* katello-certs-tools-1.2.1-1h.el6_3.noarch
* katello-cli-1.2.4-2h.el6_3.noarch
* katello-cli-common-1.2.4-2h.el6_3.noarch
* katello-common-1.2.6-2h.el6_3.noarch
* katello-configure-1.2.3-1h.el6_3.noarch
* katello-glue-candlepin-1.2.6-2h.el6_3.noarch
* katello-headpin-1.2.6-2h.el6_3.noarch
* katello-headpin-all-1.2.6-2h.el6_3.noarch
* katello-selinux-1.2.1-1h.el6_3.noarch
* thumbslug-0.0.27-1.el6_3.noarch
* thumbslug-selinux-0.0.27-1.el6_3.noarch

Comment 8 errata-xmlrpc 2013-02-21 19:18:36 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.

http://rhn.redhat.com/errata/RHSA-2013-0544.html