Bug #24334
closedActiveRecord::UnknownAttributeError: unknown attribute 'sourcerpm' for Katello::Srpm.
Description
Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1584656
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.
- 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
~~
- 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
Updated by The Foreman Bot over 6 years ago
- Status changed from New to Ready For Testing
- Assignee set to Stephen Benjamin
- Pull request https://github.com/Katello/katello/pull/7550 added
Updated by Stephen Benjamin over 6 years ago
- Status changed from Ready For Testing to Closed
Applied in changeset katello|cbd6775e335128b6305c38fd57cd4001ff10cc55.
Updated by Andrew Kofink over 6 years ago
- Subject changed from ActiveRecord::UnknownAttributeError: unknown attribute 'sourcerpm' for Katello::Srpm. to ActiveRecord::UnknownAttributeError: unknown attribute 'sourcerpm' for Katello::Srpm.
- Target version set to Katello 3.9.0