Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1584656

Summary: ActiveRecord::UnknownAttributeError: unknown attribute 'sourcerpm' for Katello::Srpm.
Product: Red Hat Satellite Reporter: Kenny Tordeurs <ktordeur>
Component: RepositoriesAssignee: Stephen Benjamin <stbenjam>
Status: CLOSED ERRATA QA Contact: Peter Ondrejka <pondrejk>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.3.1CC: aperotti, arahaman, egolov, inecas, mkearey, mmccune
Target Milestone: 6.4.0Keywords: Triaged
Target Release: Unused   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: tfm-rubygem-katello-3.7.0.11-1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-10-16 19:01:00 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:    
Bug Blocks: 1353215    

Description Kenny Tordeurs 2018-05-31 11:55:10 UTC
Description of problem:
When running `foreman-rake katello:reimport` hitting the following error:
~~~
# foreman-rake katello:reimport
Importing Katello::Erratum
Importing Katello::PackageGroup
Importing Katello::PuppetModule
Importing Katello::Rpm
Importing Katello::Srpm
rake aborted!
ActiveRecord::UnknownAttributeError: unknown attribute 'sourcerpm' for Katello::Srpm.
/opt/rh/rh-ror42/root/usr/share/gems/gems/activerecord-4.2.6/lib/active_record/attribute_assignment.rb:59:in `rescue in _assign_attribute'
/opt/rh/rh-ror42/root/usr/share/gems/gems/activerecord-4.2.6/lib/active_record/attribute_assignment.rb:53:in `_assign_attribute'
/opt/rh/rh-ror42/root/usr/share/gems/gems/activerecord-4.2.6/lib/active_record/attribute_assignment.rb:41:in `block in assign_attributes'
/opt/rh/rh-ror42/root/usr/share/gems/gems/activerecord-4.2.6/lib/active_record/attribute_assignment.rb:35:in `each'
/opt/rh/rh-ror42/root/usr/share/gems/gems/activerecord-4.2.6/lib/active_record/attribute_assignment.rb:35:in `assign_attributes'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.64/app/models/katello/srpm.rb:22:in `update_from_json'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.64/app/models/katello/concerns/pulp_database_unit.rb:56:in `block (2 levels) in import_all'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.64/app/models/katello/concerns/pulp_database_unit.rb:51:in `each'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.64/app/models/katello/concerns/pulp_database_unit.rb:51:in `block in import_all'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.64/app/services/katello/pulp/pulp_content_unit.rb:35:in `fetch_all'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.64/app/models/katello/concerns/pulp_database_unit.rb:69:in `import_all'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.64/lib/katello/tasks/reimport.rake:36:in `block (3 levels) in <top (required)>'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.64/lib/katello/tasks/reimport.rake:34:in `each'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.64/lib/katello/tasks/reimport.rake:34:in `block (2 levels) in <top (required)>'
NoMethodError: undefined method `sourcerpm=' for #<Katello::Srpm:0x00000000bad29938>
/opt/rh/rh-ror42/root/usr/share/gems/gems/activemodel-4.2.6/lib/active_model/attribute_methods.rb:433:in `method_missing'
/opt/rh/rh-ror42/root/usr/share/gems/gems/activerecord-4.2.6/lib/active_record/attribute_assignment.rb:54:in `public_send'
/opt/rh/rh-ror42/root/usr/share/gems/gems/activerecord-4.2.6/lib/active_record/attribute_assignment.rb:54:in `_assign_attribute'
/opt/rh/rh-ror42/root/usr/share/gems/gems/activerecord-4.2.6/lib/active_record/attribute_assignment.rb:41:in `block in assign_attributes'
/opt/rh/rh-ror42/root/usr/share/gems/gems/activerecord-4.2.6/lib/active_record/attribute_assignment.rb:35:in `each'
/opt/rh/rh-ror42/root/usr/share/gems/gems/activerecord-4.2.6/lib/active_record/attribute_assignment.rb:35:in `assign_attributes'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.64/app/models/katello/srpm.rb:22:in `update_from_json'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.64/app/models/katello/concerns/pulp_database_unit.rb:56:in `block (2 levels) in import_all'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.64/app/models/katello/concerns/pulp_database_unit.rb:51:in `each'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.64/app/models/katello/concerns/pulp_database_unit.rb:51:in `block in import_all'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.64/app/services/katello/pulp/pulp_content_unit.rb:35:in `fetch_all'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.64/app/models/katello/concerns/pulp_database_unit.rb:69:in `import_all'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.64/lib/katello/tasks/reimport.rake:36:in `block (3 levels) in <top (required)>'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.64/lib/katello/tasks/reimport.rake:34:in `each'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.64/lib/katello/tasks/reimport.rake:34:in `block (2 levels) in <top (required)>'
Tasks: TOP => katello:reimport
(See full trace by running task with --trace)
~~~

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

How reproducible:
Some customers hit it, could not reproduce it on internal Satellite (yet)

Steps to Reproduce:
1.
2.
3.

Actual results:
# foreman-rake katello:reimport
Importing Katello::Erratum
Importing Katello::PackageGroup
Importing Katello::PuppetModule
Importing Katello::Rpm
Importing Katello::Srpm
rake aborted!
ActiveRecord::UnknownAttributeError: unknown attribute 'sourcerpm' for Katello::Srpm.
/opt/rh/rh-ror42/root/usr/share/gems/gems/activerecord-4.2.6/lib/active_record/attribute_assignment.rb:59:in `rescue in _assign_attribute'
/opt/rh/rh-ror42/root/usr/share/gems/gems/activerecord-4.2.6/lib/active_record/attribute_assignment.rb:53:in `_assign_attribute'
/opt/rh/rh-ror42/root/usr/share/gems/gems/activerecord-4.2.6/lib/active_record/attribute_assignment.rb:41:in `block in assign_attributes'
/opt/rh/rh-ror42/root/usr/share/gems/gems/activerecord-4.2.6/lib/active_record/attribute_assignment.rb:35:in `each'
/opt/rh/rh-ror42/root/usr/share/gems/gems/activerecord-4.2.6/lib/active_record/attribute_assignment.rb:35:in `assign_attributes'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.64/app/models/katello/srpm.rb:22:in `update_from_json'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.64/app/models/katello/concerns/pulp_database_unit.rb:56:in `block (2 levels) in import_all'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.64/app/models/katello/concerns/pulp_database_unit.rb:51:in `each'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.64/app/models/katello/concerns/pulp_database_unit.rb:51:in `block in import_all'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.64/app/services/katello/pulp/pulp_content_unit.rb:35:in `fetch_all'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.64/app/models/katello/concerns/pulp_database_unit.rb:69:in `import_all'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.64/lib/katello/tasks/reimport.rake:36:in `block (3 levels) in <top (required)>'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.64/lib/katello/tasks/reimport.rake:34:in `each'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.64/lib/katello/tasks/reimport.rake:34:in `block (2 levels) in <top (required)>'
NoMethodError: undefined method `sourcerpm=' for #<Katello::Srpm:0x00000000bad29938>
/opt/rh/rh-ror42/root/usr/share/gems/gems/activemodel-4.2.6/lib/active_model/attribute_methods.rb:433:in `method_missing'
/opt/rh/rh-ror42/root/usr/share/gems/gems/activerecord-4.2.6/lib/active_record/attribute_assignment.rb:54:in `public_send'
/opt/rh/rh-ror42/root/usr/share/gems/gems/activerecord-4.2.6/lib/active_record/attribute_assignment.rb:54:in `_assign_attribute'
/opt/rh/rh-ror42/root/usr/share/gems/gems/activerecord-4.2.6/lib/active_record/attribute_assignment.rb:41:in `block in assign_attributes'
/opt/rh/rh-ror42/root/usr/share/gems/gems/activerecord-4.2.6/lib/active_record/attribute_assignment.rb:35:in `each'
/opt/rh/rh-ror42/root/usr/share/gems/gems/activerecord-4.2.6/lib/active_record/attribute_assignment.rb:35:in `assign_attributes'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.64/app/models/katello/srpm.rb:22:in `update_from_json'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.64/app/models/katello/concerns/pulp_database_unit.rb:56:in `block (2 levels) in import_all'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.64/app/models/katello/concerns/pulp_database_unit.rb:51:in `each'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.64/app/models/katello/concerns/pulp_database_unit.rb:51:in `block in import_all'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.64/app/services/katello/pulp/pulp_content_unit.rb:35:in `fetch_all'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.64/app/models/katello/concerns/pulp_database_unit.rb:69:in `import_all'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.64/lib/katello/tasks/reimport.rake:36:in `block (3 levels) in <top (required)>'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.64/lib/katello/tasks/reimport.rake:34:in `each'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.64/lib/katello/tasks/reimport.rake:34:in `block (2 levels) in <top (required)>'
Tasks: TOP => katello:reimport
(See full trace by running task with --trace)


Expected results:
Reimport to complete

Additional info:
This is caused because of a bug in [0] there is the attribute sourcerpm that should not be there:

# for i in `locate srpm.rb` ; do grep sourcerpm $i && echo $i ; done
~~~
PULP_INDEXED_FIELDS = %w(name version release arch epoch summary sourcerpm checksum filename _id).freeze
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.64/app/services/katello/pulp/srpm.rb
~~~

I believe for you it will be the following file:
# vim /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.64/app/services/katello/pulp/srpm.rb

~~~
diff -up /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.64/app/services/katello/pulp/srpm.rb.bkp /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.64/app/services/katello/pulp/srpm.rb
--- /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.64/app/services/katello/pulp/srpm.rb.bkp	2018-05-30 15:51:08.333710843 +0200
+++ /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.64/app/services/katello/pulp/srpm.rb	2018-05-30 15:51:45.655385661 +0200
@@ -4,7 +4,7 @@ module Katello
       include LazyAccessor
 
       PULP_SELECT_FIELDS = %w(name epoch version release arch checksumtype checksum).freeze
-      PULP_INDEXED_FIELDS = %w(name version release arch epoch summary sourcerpm checksum filename _id).freeze
+      PULP_INDEXED_FIELDS = %w(name version release arch epoch summary checksum filename _id).freeze
       CONTENT_TYPE = "srpm".freeze
 
       lazy_accessor :pulp_facts, :initializer => :backend_data
~~~

[0] https://github.com/Katello/katello/blob/master/app/services/katello/pulp/srpm.rb#L7

Comment 3 Stephen Benjamin 2018-07-20 17:24:07 UTC
Created redmine issue https://projects.theforeman.org/issues/24334 from this bug

Comment 4 Satellite Program 2018-07-20 18:21:06 UTC
Upstream bug assigned to stbenjam

Comment 5 Satellite Program 2018-07-20 18:21:10 UTC
Upstream bug assigned to stbenjam

Comment 6 Satellite Program 2018-07-25 16:21:08 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/24334 has been resolved.

Comment 9 Peter Ondrejka 2018-09-05 14:17:03 UTC
Verified on Satellite 6.4 snap 20 using steps from https://github.com/Katello/katello/pull/7550

Comment 10 Bryan Kearney 2018-10-16 19:01:00 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:2927