Bug: Host group settings not saved (Foreman 2.2/Katello 3.17)

So I have an update on the Ansible side of things, I have changed my theforeman.foreman.hostgroup task to create the hostgroup without specifying the kickstart repository, and that works on Katello 3.18 (I didn’t test it specifically on 3.17, I suspect it will work).

Existing groups still need some love, but this fixes new groups for now :slight_smile:

@Thulium-Drake I looked into this bug and have filed the following PR -> Fixes #31382 - Hostgroup content facet migration fix by parthaa · Pull Request #9095 · Katello/katello · GitHub

It’d be great if you could apply that 1 line patch to

/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.17.1/db/migrate/20200514092553_move_katello_fields_from_hostgroups.katello.rb (similar location for 3-18)

Then run the foreman-installer for the upgrade and confirm. Please update the pull request if it works for you.

1 Like

Thanks! I’ll look into it and let you know in a few :wink:

Alas, no dice. This is a freshly installed Foreman 2.1 server configured with hostgroups, but the foreman-installer upgrade fails when running the db:migrate command.

As it is a test machine, I’ll leave it hanging like this, so I can do further troubleshooting if you want to know more :slight_smile:

[root@foreman ~]# /usr/sbin/foreman-rake db:migrate --trace
** Invoke db:migrate (first_time)
** Invoke db:load_config (first_time)
** Invoke environment (first_time)
** Execute environment
API controllers newer than Apipie cache! Run apipie:cache rake task to regenerate cache.
** Execute db:load_config
** Invoke plugin:refresh_migrations (first_time)
** Invoke environment 
** Execute plugin:refresh_migrations
** Execute db:migrate
== 20200514092553 MoveKatelloFieldsFromHostgroups: migrating ==================
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

Validation failed: The selected kickstart repository is not part of the assigned content view, lifecycle environment,
                  content source, operating system, and architecture
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/validations.rb:80:in `raise_validation_error'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/validations.rb:53:in `save!'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/transactions.rb:318:in `block in save!'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/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.1/lib/active_record/connection_adapters/abstract/database_statements.rb:278:in `transaction'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/transactions.rb:212:in `transaction'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/transactions.rb:366:in `with_transaction_returning_status'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/transactions.rb:318:in `save!'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/suppressor.rb:48:in `save!'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.17.1/db/migrate/20200514092553_move_katello_fields_from_hostgroups.katello.rb:49:in `block (2 levels) in copy_data_from_hostgroup'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.17.1/db/migrate/20200514092553_move_katello_fields_from_hostgroups.katello.rb:43:in `each'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.17.1/db/migrate/20200514092553_move_katello_fields_from_hostgroups.katello.rb:43:in `block in copy_data_from_hostgroup'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/relation/batches.rb:238:in `block in in_batches'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/relation/batches.rb:222:in `loop'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/relation/batches.rb:222:in `in_batches'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.17.1/db/migrate/20200514092553_move_katello_fields_from_hostgroups.katello.rb:36:in `copy_data_from_hostgroup'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.17.1/db/migrate/20200514092553_move_katello_fields_from_hostgroups.katello.rb:5:in `block in up'
/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-3.17.1/db/migrate/20200514092553_move_katello_fields_from_hostgroups.katello.rb:4:in `up'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:831:in `exec_migration'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:812:in `block (2 levels) in migrate'
/opt/rh/rh-ruby25/root/usr/share/ruby/benchmark.rb:293:in `measure'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:811:in `block in migrate'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:471:in `with_connection'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:810:in `migrate'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1002:in `migrate'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1310:in `block in execute_migration_in_transaction'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1361:in `block in ddl_transaction'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/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.1/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.1/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.1/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.1/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.1/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.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/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.1/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in `transaction'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/transactions.rb:212:in `transaction'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1361:in `ddl_transaction'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1309:in `execute_migration_in_transaction'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1281:in `block in migrate_without_lock'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1280:in `each'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1280:in `migrate_without_lock'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1229:in `block in migrate'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1382:in `with_advisory_lock'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1229:in `migrate'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1061:in `up'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1036:in `migrate'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/tasks/database_tasks.rb:238:in `migrate'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/railties/databases.rake:86:in `block (3 levels) in <top (required)>'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/railties/databases.rake:84:in `each'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/railties/databases.rake:84:in `block (2 levels) in <top (required)>'
/opt/rh/rh-ruby25/root/usr/share/gems/gems/rake-12.3.0/lib/rake/task.rb:251:in `block in execute'
/opt/rh/rh-ruby25/root/usr/share/gems/gems/rake-12.3.0/lib/rake/task.rb:251:in `each'
/opt/rh/rh-ruby25/root/usr/share/gems/gems/rake-12.3.0/lib/rake/task.rb:251:in `execute'
/opt/rh/rh-ruby25/root/usr/share/gems/gems/rake-12.3.0/lib/rake/task.rb:195:in `block in invoke_with_call_chain'
/opt/rh/rh-ruby25/root/usr/share/ruby/monitor.rb:226:in `mon_synchronize'
/opt/rh/rh-ruby25/root/usr/share/gems/gems/rake-12.3.0/lib/rake/task.rb:188:in `invoke_with_call_chain'
/opt/rh/rh-ruby25/root/usr/share/gems/gems/rake-12.3.0/lib/rake/task.rb:181:in `invoke'
/opt/rh/rh-ruby25/root/usr/share/gems/gems/rake-12.3.0/lib/rake/application.rb:160:in `invoke_task'
/opt/rh/rh-ruby25/root/usr/share/gems/gems/rake-12.3.0/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/opt/rh/rh-ruby25/root/usr/share/gems/gems/rake-12.3.0/lib/rake/application.rb:116:in `each'
/opt/rh/rh-ruby25/root/usr/share/gems/gems/rake-12.3.0/lib/rake/application.rb:116:in `block in top_level'
/opt/rh/rh-ruby25/root/usr/share/gems/gems/rake-12.3.0/lib/rake/application.rb:125:in `run_with_threads'
/opt/rh/rh-ruby25/root/usr/share/gems/gems/rake-12.3.0/lib/rake/application.rb:110:in `top_level'
/opt/rh/rh-ruby25/root/usr/share/gems/gems/rake-12.3.0/lib/rake/application.rb:83:in `block in run'
/opt/rh/rh-ruby25/root/usr/share/gems/gems/rake-12.3.0/lib/rake/application.rb:186:in `standard_exception_handling'
/opt/rh/rh-ruby25/root/usr/share/gems/gems/rake-12.3.0/lib/rake/application.rb:80:in `run'
/opt/rh/rh-ruby25/root/usr/share/gems/gems/rake-12.3.0/exe/rake:27:in `<top (required)>'
/opt/rh/rh-ruby25/root/usr/bin/rake:23:in `load'
/opt/rh/rh-ruby25/root/usr/bin/rake:23:in `<main>'

Caused by:
ActiveRecord::RecordInvalid: Validation failed: The selected kickstart repository is not part of the assigned content view, lifecycle environment,
                  content source, operating system, and architecture
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/validations.rb:80:in `raise_validation_error'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/validations.rb:53:in `save!'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/transactions.rb:318:in `block in save!'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/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.1/lib/active_record/connection_adapters/abstract/database_statements.rb:278:in `transaction'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/transactions.rb:212:in `transaction'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/transactions.rb:366:in `with_transaction_returning_status'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/transactions.rb:318:in `save!'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/suppressor.rb:48:in `save!'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.17.1/db/migrate/20200514092553_move_katello_fields_from_hostgroups.katello.rb:49:in `block (2 levels) in copy_data_from_hostgroup'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.17.1/db/migrate/20200514092553_move_katello_fields_from_hostgroups.katello.rb:43:in `each'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.17.1/db/migrate/20200514092553_move_katello_fields_from_hostgroups.katello.rb:43:in `block in copy_data_from_hostgroup'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/relation/batches.rb:238:in `block in in_batches'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/relation/batches.rb:222:in `loop'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/relation/batches.rb:222:in `in_batches'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.17.1/db/migrate/20200514092553_move_katello_fields_from_hostgroups.katello.rb:36:in `copy_data_from_hostgroup'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.17.1/db/migrate/20200514092553_move_katello_fields_from_hostgroups.katello.rb:5:in `block in up'
/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-3.17.1/db/migrate/20200514092553_move_katello_fields_from_hostgroups.katello.rb:4:in `up'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:831:in `exec_migration'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:812:in `block (2 levels) in migrate'
/opt/rh/rh-ruby25/root/usr/share/ruby/benchmark.rb:293:in `measure'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:811:in `block in migrate'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:471:in `with_connection'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:810:in `migrate'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1002:in `migrate'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1310:in `block in execute_migration_in_transaction'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1361:in `block in ddl_transaction'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/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.1/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.1/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.1/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.1/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.1/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.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/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.1/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in `transaction'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/transactions.rb:212:in `transaction'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1361:in `ddl_transaction'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1309:in `execute_migration_in_transaction'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1281:in `block in migrate_without_lock'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1280:in `each'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1280:in `migrate_without_lock'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1229:in `block in migrate'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1382:in `with_advisory_lock'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1229:in `migrate'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1061:in `up'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1036:in `migrate'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/tasks/database_tasks.rb:238:in `migrate'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/railties/databases.rake:86:in `block (3 levels) in <top (required)>'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/railties/databases.rake:84:in `each'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/railties/databases.rake:84:in `block (2 levels) in <top (required)>'
/opt/rh/rh-ruby25/root/usr/share/gems/gems/rake-12.3.0/lib/rake/task.rb:251:in `block in execute'
/opt/rh/rh-ruby25/root/usr/share/gems/gems/rake-12.3.0/lib/rake/task.rb:251:in `each'
/opt/rh/rh-ruby25/root/usr/share/gems/gems/rake-12.3.0/lib/rake/task.rb:251:in `execute'
/opt/rh/rh-ruby25/root/usr/share/gems/gems/rake-12.3.0/lib/rake/task.rb:195:in `block in invoke_with_call_chain'
/opt/rh/rh-ruby25/root/usr/share/ruby/monitor.rb:226:in `mon_synchronize'
/opt/rh/rh-ruby25/root/usr/share/gems/gems/rake-12.3.0/lib/rake/task.rb:188:in `invoke_with_call_chain'
/opt/rh/rh-ruby25/root/usr/share/gems/gems/rake-12.3.0/lib/rake/task.rb:181:in `invoke'
/opt/rh/rh-ruby25/root/usr/share/gems/gems/rake-12.3.0/lib/rake/application.rb:160:in `invoke_task'
/opt/rh/rh-ruby25/root/usr/share/gems/gems/rake-12.3.0/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/opt/rh/rh-ruby25/root/usr/share/gems/gems/rake-12.3.0/lib/rake/application.rb:116:in `each'
/opt/rh/rh-ruby25/root/usr/share/gems/gems/rake-12.3.0/lib/rake/application.rb:116:in `block in top_level'
/opt/rh/rh-ruby25/root/usr/share/gems/gems/rake-12.3.0/lib/rake/application.rb:125:in `run_with_threads'
/opt/rh/rh-ruby25/root/usr/share/gems/gems/rake-12.3.0/lib/rake/application.rb:110:in `top_level'
/opt/rh/rh-ruby25/root/usr/share/gems/gems/rake-12.3.0/lib/rake/application.rb:83:in `block in run'
/opt/rh/rh-ruby25/root/usr/share/gems/gems/rake-12.3.0/lib/rake/application.rb:186:in `standard_exception_handling'
/opt/rh/rh-ruby25/root/usr/share/gems/gems/rake-12.3.0/lib/rake/application.rb:80:in `run'
/opt/rh/rh-ruby25/root/usr/share/gems/gems/rake-12.3.0/exe/rake:27:in `<top (required)>'
/opt/rh/rh-ruby25/root/usr/bin/rake:23:in `load'
/opt/rh/rh-ruby25/root/usr/bin/rake:23:in `<main>'
Tasks: TOP => db:migrate

This is a different issue. Need to figure out which hostgroup is it complaining about. How many hostgroups you have in your db.
Even if there is something wrong with the data it should not block the migration. Will look into it.

Not completely, if you check my first post, this is the same error as Ansible ran into when trying to create a hostgroup on Katello 3.17+ if the tasks had the kickstart_repository argument set.

If you want, I can whip up a small example with my Ansible role for you to deploy and test.

Sure. I can take a look around. Are you not able to create any hostgroup with content stuff at all via ansible? or is it something specific to this.

Also can you try applying this patch -> Fixes #31544 - properly check for content source on new hostgroup by jlsherrill · Pull Request #9084 · Katello/katello · GitHub and running the migrate again ?

It has something to do with this. When I first wrote my role, I defined hostgroups by setting all required settings (including kickstart_repository). And after upgrading to 2.2/3.17 that task was no longer able to complete succesfully, citing

The selected kickstart repository is not part of the assigned content view, lifecycle environment

as the error.

When I was looking into this, I noticed that when I didn’t specify the kickstart_repository it would work.

The code that does the job is here: ansible-role-foreman/host_groups.yml at master · Thulium-Drake/ansible-role-foreman · GitHub (yes, the loop is horribly complicated, but it’s the only way to automatically match hostgroups with activation keys :slight_smile: )

I’m still working on the example (I need to take an existing config and strip it down for clarity’s sake), I’ll get back to you on that!

The 2nd PR I asked you to patch seems to address the “kickstart repository is not part of the assigned content view, lifecycle environment” part of the issue. If you can confirm that fixes it, I can make sure I add warnings and stuff.

I’m still deploying a fresh server (when I added it to the server I installed earlier it didn’t fix it).

I should know in a bit :slight_smile: it’s almost done installing and I stripped all repo’s except the CentOS7 BaseOS repo to speed up the syncing.

Well, I ran the update on my newly installed example server (see for Ansible code here: foreman-debug.tar.xz.gz (2.7 MB), remove the gz, it is Xzipped. )

No dice, it didn’t crash during the upgrade, but the katello_hostgroup_content_facets table remains empty…

As does Hammer’s output:

[root@foreman ~]# hammer hostgroup show --id 1
Id:                    1
Name:                  CentOS7-Base-Infra
Title:                 CentOS7-Base-Infra
Description:           
  Managed by Ansible, your changes will be lost
Network:               
    Subnet ipv4: Infra
    Domain:      example.lab
Operating system:      
    Architecture:     x86_64
    Operating System: CentOS 7
    Partition Table:  Kickstart default
    PXE Loader:       PXELinux BIOS
Puppetclasses:         

Parameters:            
    kt_activation_keys => CentOS7-Base-Infra
Locations:             
    Somewhere
Organizations:         
    Admin
Content View:          
    ID:   
    Name:
Lifecycle Environment: 
    ID:   
    Name:
Content Source:        
    ID:   
    Name:
Kickstart Repository:  
    ID:

Let me know if you can reproduce it with the code I sent you :slight_smile:

Do you see a warning in your /var/log/foreman/production.log along the lines of
“Unable to save content facet hostgroup for…”

I 'll try repro’ing…

Nope… This is all I was able to find:

[root@foreman ~]# zgrep facet /var/log/foreman/production.log* 
/var/log/foreman/production.log-20210114.gz:2021-01-13T17:55:55 [I|aud|] Katello::KTEnvironment (1) create event on content_facet_ids []
/var/log/foreman/production.log-20210114.gz:2021-01-13T18:34:22 [I|aud|] Katello::KTEnvironment (2) create event on content_facet_ids []
/var/log/foreman/production.log-20210114.gz:2021-01-13T18:34:27 [I|aud|27003877] Katello::KTEnvironment (3) create event on content_facet_ids []
/var/log/foreman/production.log-20210114.gz:2021-01-13T18:34:28 [I|aud|322bef25] Katello::KTEnvironment (4) create event on content_facet_ids []
/var/log/foreman/production.log-20210114.gz:2021-01-13T18:34:29 [I|aud|b9765d4c] Katello::KTEnvironment (5) create event on content_facet_ids []
/var/log/foreman/production.log-20210114.gz:2021-01-13T18:34:30 [I|aud|ff517cec] Katello::KTEnvironment (6) create event on content_facet_ids []

What I did was the following:

  1. Install a server with the code I sent
  2. Update all packages to 3.17
  3. Apply patch to /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.17.1/app/models/katello/concerns/redhat_extensions.rb
  4. Run foreman-installer

It also didn’t crash this time, so it didn’t break anything.

@Partha_Aji Any luck? :slight_smile:

@Thulium-Drake still working on it. Can you try the following

  1. Install a server with the code you sent
  2. Update all packages to 3.17
  3. Apply patch to /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.17.1/app/models/katello/concerns/redhat_extensions.rb
    4, Apply Fixes #31382 - Hostgroup content facet migration fix by parthaa · Pull Request #9095 · Katello/katello · GitHub patch also to
    /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.17.1/db/migrate/20200514092553_move_katello_fields_from_hostgroups.katello.rb
  4. Run foreman-installer

Basically both patches are needed.

Hi @Partha_Aji ,

Sorry for the delay, installing a fresh VM now, I’ll let you know in a few :slight_smile:

So, I just wrapped up the upgrade. It’s improving, but not there yet.

After running the upgrade, the katello_hostgroup_content_facets table looked like this:

foreman-# select * from katello_hostgroup_content_facets;
 id | hostgroup_id | kickstart_repository_id | content_source_id | content_view_id | lifecycle_environment_id 
----+--------------+-------------------------+-------------------+-----------------+--------------------------
  1 |            1 |                         |                   |                 |                         
(1 row)

Which is better, but still incomplete. But there is progress! After manually editing the hostgroup (setting the LCE, source and kickstart repo again) it looked like this:

foreman=# select * from katello_hostgroup_content_facets;
 id | hostgroup_id | kickstart_repository_id | content_source_id | content_view_id | lifecycle_environment_id 
----+--------------+-------------------------+-------------------+-----------------+--------------------------
  1 |            1 |                      12 |                 1 |               5 |                        3
(1 row)

So there is progress, but we’re not out of the woods yet… I also retried to run it with Ansible, but no dice, however, as mentioned, there is a workaround there by leaving the kickstart_repo parameter undefined.

Hello, is there already a fix available for the behavior. After the upgrade from version 3.15 to 3.17 all host groups are broken. I have applied the changes to the rb files as described before running foreman-installer. But still the same problem. Steps… 3.15 installation… host groups are ok, Upgrade to 3.17, apply fix to both rb files, run foreman-installer sucessfully, host groups are damaged… Best regards, Tom

We have the same problem here. We are actually stucked with Foreman 2.1 and Katello 3.16.
Please release Katello 3.17.x with a fix.
Thank you, Sebastian