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-126.96.36.199/lib/active_record/relation/delegation.rb:87:in `each' /usr/share/gems/gems/activerecord-188.8.131.52/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-184.108.40.206/lib/active_record/migration.rb:831:in `exec_migration' /usr/share/gems/gems/activerecord-220.127.116.11/lib/active_record/migration.rb:812:in `block (2 levels) in migrate' /usr/share/gems/gems/activerecord-18.104.22.168/lib/active_record/migration.rb:811:in `block in migrate' /usr/share/gems/gems/activerecord-22.214.171.124/lib/active_record/connection_adapters/abstract/connection_pool.rb:471:in `with_connection' /usr/share/gems/gems/activerecord-126.96.36.199/lib/active_record/migration.rb:810:in `migrate' /usr/share/gems/gems/activerecord-188.8.131.52/lib/active_record/migration.rb:1002:in `migrate' /usr/share/gems/gems/activerecord-184.108.40.206/lib/active_record/migration.rb:1310:in `block in execute_migration_in_transaction
Foreman and Proxy versions:
Foreman and Proxy plugin versions:
Distribution and version:
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?