Hi,
I'm facing an error when trying to upgrade from Katello 2.4 to 3.0. The
task katello:upgrades:3.0:update_subscription_facet_backend_data fails
with: ActiveRecord::RecordNotFound: Couldn't find Host::Managed with
'id'=172 [WHERE "hosts"."type" IN ('Host::Managed')]
I have tried to remove the system with foreman-rake console but once I run
again the Katello upgrade task, it will come back again with a new ID:
foreman-rake console
Katello::System.find_by(:host_id=> 172).try(:destroy!)
host = Katello::Host::SubscriptionFacet.find_by(:host_id=> 172).try(:host)
host.subscription_facet.try(:destroy! ) if host
host.content_facet.try(:destroy!) if host
The full error output
[root@mbsbkkkatp01 ~]# foreman-rake
katello:upgrades:3.0:update_subscription_facet_backend_data --trace
** Invoke katello:upgrades:3.0:update_subscription_facet_backend_data
(first_time)
** Invoke environment (first_time)
** Execute environment
** Execute katello:upgrades:3.0:update_subscription_facet_backend_data
Updating backend data for subscription facets
rake aborted!
ActiveRecord::RecordNotFound: Couldn't find Host::Managed with 'id'=172
[WHERE "hosts"."type" IN ('Host::Managed')]
/opt/rh/rh-ror41/root/usr/share/gems/gems/activerecord-4.1.5/lib/active_record/relation/finder_methods.rb:320:in
raise_record_not_found_exception!' /opt/rh/rh-ror41/root/usr/share/gems/gems/activerecord-4.1.5/lib/active_record/relation/finder_methods.rb:420:in
find_one'
/opt/rh/rh-ror41/root/usr/share/gems/gems/activerecord-4.1.5/lib/active_record/relation/finder_methods.rb:404:in
find_with_ids' /opt/rh/rh-ror41/root/usr/share/gems/gems/activerecord-4.1.5/lib/active_record/relation/finder_methods.rb:68:in
find'
/opt/rh/rh-ror41/root/usr/share/gems/gems/activerecord-4.1.5/lib/active_record/querying.rb:3:in
find' /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.0.2/lib/katello/tasks/upgrades/3.0/update_subscription_facet_backend_data.rake:13:in
block (5 levels) in <top (required)>'
/opt/rh/rh-ror41/root/usr/share/gems/gems/activerecord-4.1.5/lib/active_record/relation/batches.rb:52:in
block (2 levels) in find_each' /opt/rh/rh-ror41/root/usr/share/gems/gems/activerecord-4.1.5/lib/active_record/relation/batches.rb:52:in
each'
/opt/rh/rh-ror41/root/usr/share/gems/gems/activerecord-4.1.5/lib/active_record/relation/batches.rb:52:in
block in find_each' /opt/rh/rh-ror41/root/usr/share/gems/gems/activerecord-4.1.5/lib/active_record/relation/batches.rb:125:in
find_in_batches'
/opt/rh/rh-ror41/root/usr/share/gems/gems/activerecord-4.1.5/lib/active_record/relation/batches.rb:51:in
find_each' /opt/rh/rh-ror41/root/usr/share/gems/gems/activerecord-4.1.5/lib/active_record/querying.rb:9:in
find_each'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.0.2/lib/katello/tasks/upgrades/3.0/update_subscription_facet_backend_data.rake:8:in
block (4 levels) in <top (required)>' /opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:240:in
call'
/opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:240:in
block in execute' /opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:235:in
each'
/opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:235:in
execute' /opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:179:in
block in invoke_with_call_chain'
/opt/rh/rh-ruby22/root/usr/share/ruby/monitor.rb:211:in mon_synchronize' /opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:172:in
invoke_with_call_chain'
/opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:165:in
invoke' /opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:150:in
invoke_task'
/opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:106:in
block (2 levels) in top_level' /opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:106:in
each'
/opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:106:in
block in top_level' /opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:115:in
run_with_threads'
/opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:100:in
top_level' /opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:78:in
block in run'
/opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:176:in
standard_exception_handling' /opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:75:in
run'
/opt/rh/rh-ruby22/root/usr/bin/rake:33:in `<main>'
Tasks: TOP => katello:upgrades:3.0:update_subscription_facet_backend_data
I don't mind to remove all the subscriptions and assign again after as part
of the solution.
What can I do?
Best Regards,
Joaquin