Problem:
When upgrading - the Rake Tasks fail - specifically:
Rubocop not loaded.
Apipie cache enabled but not present yet. Run apipie:cache rake task to speed up API calls.
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
Notice: /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]/returns:
undefined method `operatingsystems' for nil:NilClass
/usr/share/foreman/db/migrate/20210115124508_template_kind_registration.rb:26:in `block in up'
/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/relation/delegation.rb:87:in `each'
/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/relation/delegation.rb:87:in `each'
/usr/share/foreman/db/migrate/20210115124508_template_kind_registration.rb:25:in `up'
/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:831:in `exec_migration'
/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:812:in `block (2 levels) in migrate'
/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:811:in `block in migrate'
/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:471:in `with_connection'
/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:810:in `migrate'
/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1002:in `migrate'
/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1310:in `block in execute_migration_in_transaction
ā
Expected outcome:
It Succeeds
Foreman and Proxy versions:
Foreman 3.0
Foreman and Proxy plugin versions:
Foreman 3.0
Distribution and version:
Foreman 3.0
Other relevant data:
We believe we have the issue traced back to this Bug/PR: https://projects.theforeman.org/issues/31663
This Commit: https://github.com/theforeman/foreman/pull/8256
This Line: https://github.com/theforeman/foreman/blob/3.0.0/db/migrate/20210115124508_template_kind_registration.rb#L26
Logically - it looks like in 1.24 neither āLinux registration defaultā or ādefault_host_init_config_templateā exist yet. Following the logic up to line 26, it essentially āskipsā most of it - then whines because at line 26 itās nil. Iām unsure if a seed task would/should ācreateā these - i canāt find any other references in the codebase as to how they get created initially, either in seeds, or migrations. However - i cannot run a āseedā until the migration completes either :-X
in our lab we were able to āwork aroundā it by using the ruby console to create the missing āoldā value manually - after which it āworkedā in that it completed successfully without erroring. Still working out whether this is āokā or if it just missed something important.
Our error seems somewhat similar to the comment by āaresā on the PR above: https://github.com/theforeman/foreman/pull/8256#issuecomment-787467165
At the end of the day - we are skipping several major versions, but i believe the migrations are supposed to be fully atomic, and it seems like they arenāt quite for this setting migration at least?