Upgrade Foreman from 2.4 to 2.5 and katello from 4.0.2.1 to 4.1

Problem:
foreman-installer dows not finish and show:
[ERROR ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:seed]/Exec[foreman-rake-db:seed]: Failed to call refresh: ‘/usr/sbin/foreman-rake db:seed’ returned 1 instead of one of [0]
[ERROR ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:seed]/Exec[foreman-rake-db:seed]: ‘/usr/sbin/foreman-rake db:seed’ returned 1 instead of one of [0]

foreman-rake dp:seed --trace show:
ActiveRecord::RecordInvalid: Validation failed: Hostgroups expecting hostgroups used by hosts or inherited (check mismatches report).

Expected outcome:

Foreman and Proxy versions:
Forreman smart proxes 3.4.1
Foreman and Proxy plugin versions:
foreman-tasks 4.0.1
foreman_docker 5.0.0
foreman_remote_execution 4.3.0
katello 4.0.2.1

Distribution and version:

Other relevant data:

ActiveRecord::RecordInvalid: Validation failed: Hostgroups expecting hostgroups used by hosts or inherited (check mismatches report).
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/validations.rb:80:in raise_validation_error' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/validations.rb:53:in save!’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/transactions.rb:318:in block in save!' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/transactions.rb:375:in block in with_transaction_returning_status’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/database_statements.rb:278:in transaction' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/transactions.rb:212:in transaction’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/transactions.rb:366:in with_transaction_returning_status' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/transactions.rb:318:in save!’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/suppressor.rb:48:in save!' /opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.3/app/lib/katello/lazy_accessor.rb:67:in save!’
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-4.1.4/app/models/foreman_tasks/concerns/action_triggering.rb:31:in block in save!' /opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-4.1.4/app/models/foreman_tasks/concerns/action_triggering.rb:127:in dynflow_task_wrap’
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-4.1.4/app/models/foreman_tasks/concerns/action_triggering.rb:31:in save!' /opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.3/app/services/katello/organization_creator.rb:31:in block in seed!’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/database_statements.rb:278:in transaction' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/transactions.rb:212:in transaction’
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.3/app/services/katello/organization_creator.rb:29:in seed!' /opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.3/app/services/katello/organization_creator.rb:8:in block (2 levels) in seed_all_organizations!’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/relation/delegation.rb:87:in each' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/relation/delegation.rb:87:in each’
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.3/app/services/katello/organization_creator.rb:7:in block in seed_all_organizations!' /usr/share/foreman/app/models/concerns/foreman/thread_session.rb:108:in as’
/usr/share/foreman/app/models/concerns/foreman/thread_session.rb:114:in as_anonymous_admin' /opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.3/app/services/katello/organization_creator.rb:6:in seed_all_organizations!’
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.3/db/seeds.d/102-organizations.rb:8:in <top (required)>' /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:318:in load’
/usr/share/foreman/app/services/foreman_seeder.rb:51:in block (3 levels) in execute' /usr/share/foreman/app/models/concerns/foreman/thread_session.rb:108:in as’
/usr/share/foreman/app/models/concerns/foreman/thread_session.rb:114:in as_anonymous_admin' /usr/share/foreman/app/services/foreman_seeder.rb:50:in block (2 levels) in execute’
/usr/share/foreman/app/services/foreman_seeder.rb:44:in each' /usr/share/foreman/app/services/foreman_seeder.rb:44:in block in execute’
/usr/share/foreman/lib/foreman/advisory_lock_manager.rb:20:in block in with_transaction_lock' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in block in transaction’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/transaction.rb:280:in block in within_new_transaction' /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in block (2 levels) in synchronize’
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in handle_interrupt' /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in block in synchronize’
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in handle_interrupt' /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in synchronize’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/transaction.rb:278:in within_new_transaction' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in transaction’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/transactions.rb:212:in transaction' /usr/share/foreman/lib/foreman/advisory_lock_manager.rb:17:in with_transaction_lock’
/usr/share/foreman/app/services/foreman_seeder.rb:38:in execute' /usr/share/foreman/db/seeds.rb:14:in <top (required)>’
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:318:in load' /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:318:in block in load’
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:291:in load_dependency' /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:318:in load’
/usr/share/foreman/config/initializers/0_print_time_spent.rb:38:in block in load' /usr/share/foreman/config/initializers/0_print_time_spent.rb:17:in benchmark’
/usr/share/foreman/config/initializers/0_print_time_spent.rb:38:in load' /opt/theforeman/tfm/root/usr/share/gems/gems/railties-6.0.3.7/lib/rails/engine.rb:559:in load_seed’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/tasks/database_tasks.rb:440:in load_seed' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/railties/databases.rake:331:in block (2 levels) in <top (required)>’
/opt/rh/rh-ruby27/root/usr/share/gems/gems/rake-13.0.1/lib/rake/task.rb:281:in block in execute' /opt/rh/rh-ruby27/root/usr/share/gems/gems/rake-13.0.1/lib/rake/task.rb:281:in each’
/opt/rh/rh-ruby27/root/usr/share/gems/gems/rake-13.0.1/lib/rake/task.rb:281:in execute' /opt/rh/rh-ruby27/root/usr/share/gems/gems/rake-13.0.1/lib/rake/task.rb:219:in block in invoke_with_call_chain’
/opt/rh/rh-ruby27/root/usr/share/gems/gems/rake-13.0.1/lib/rake/task.rb:199:in synchronize' /opt/rh/rh-ruby27/root/usr/share/gems/gems/rake-13.0.1/lib/rake/task.rb:199:in invoke_with_call_chain’
/opt/rh/rh-ruby27/root/usr/share/gems/gems/rake-13.0.1/lib/rake/task.rb:188:in invoke' /opt/rh/rh-ruby27/root/usr/share/gems/gems/rake-13.0.1/lib/rake/application.rb:160:in invoke_task’
/opt/rh/rh-ruby27/root/usr/share/gems/gems/rake-13.0.1/lib/rake/application.rb:116:in block (2 levels) in top_level' /opt/rh/rh-ruby27/root/usr/share/gems/gems/rake-13.0.1/lib/rake/application.rb:116:in each’
/opt/rh/rh-ruby27/root/usr/share/gems/gems/rake-13.0.1/lib/rake/application.rb:116:in block in top_level' /opt/rh/rh-ruby27/root/usr/share/gems/gems/rake-13.0.1/lib/rake/application.rb:125:in run_with_threads’
/opt/rh/rh-ruby27/root/usr/share/gems/gems/rake-13.0.1/lib/rake/application.rb:110:in top_level' /opt/rh/rh-ruby27/root/usr/share/gems/gems/rake-13.0.1/lib/rake/application.rb:83:in block in run’
/opt/rh/rh-ruby27/root/usr/share/gems/gems/rake-13.0.1/lib/rake/application.rb:186:in standard_exception_handling' /opt/rh/rh-ruby27/root/usr/share/gems/gems/rake-13.0.1/lib/rake/application.rb:80:in run’
/opt/rh/rh-ruby27/root/usr/share/gems/gems/rake-13.0.1/exe/rake:27:in <top (required)>' /opt/rh/rh-ruby27/root/usr/bin/rake:23:in load’
/opt/rh/rh-ruby27/root/usr/bin/rake:23:in `’
Tasks: TOP => db:seed

Error was because a Host group had been created that had not been assigned to the Organization.

Hello Carlos,

How did you resolve you issue? How did you access to be able to modify ?
I can’t access the web, and the hammer cli is not available also.

Is the only solution is to launch the foreman-installer with the last working version?
Or restore a backup with last working version?