New Redhat 8.5 installation with Foreman 3.3/Katello 4.5 restore problem of the same foreman/katello version from Redhat 7

Problem:

Candlepin probably has a problem with key reading/decrypting. Anyone have an idea how to get this working again

Expected outcome:
Foreman Katello ready to login with the existing Parameters
Foreman and Proxy versions:

Foreman and Proxy plugin versions:

Distribution and version:

Other relevant data:

foreman-maintain restore  /var/katello-backup-2022-07-22-22-25-52/
Running Restore backup
================================================================================
Check if command is run as root user:                                 [OK]
--------------------------------------------------------------------------------
Validate backup has appropriate files:                                [OK]
--------------------------------------------------------------------------------
Validate hostname is the same as backup:                              [OK]
--------------------------------------------------------------------------------
Validate network interfaces match the backup:                         [OK]
--------------------------------------------------------------------------------
Confirm dropping databases and running restore:

WARNING: This script will drop and restore your database.
Your existing installation will be replaced with the backup database.
Once this operation is complete there is no going back.
Do you want to proceed?, [y(yes), q(quit)] y
                                                                      [OK]
--------------------------------------------------------------------------------
Setting file security:
\ Restoring SELinux context                                           [OK]
--------------------------------------------------------------------------------
Restore configs from backup:
| Restoring configs                                                   [OK]
--------------------------------------------------------------------------------
Run installer reset:
\ Installer reset                                                     [FAIL]
Failed executing yes | foreman-installer -v --reset-data --disable-system-checks , exit status 1:
 2022-07-25 09:20:12 [NOTICE] [root] Loading installer configuration. This will take some time.
2022-07-25 09:20:17 [NOTICE] [root] Running installer with log based terminal output at level NOTICE.
2022-07-25 09:20:17 [NOTICE] [root] Use -l to set the terminal output log level to ERROR, WARN, NOTICE, INFO, or DEBUG. See --full-help for definitions.
Are you sure you want to continue? This will drop the databases, reset all configurations that you have made and bring all application data back to a fresh install. [y/n]
2022-07-25 09:20:24 [NOTICE] [pre] Dropping foreman database!
2022-07-25 09:20:24 [ERROR ] [root] runuser -l postgres -c 'dropdb foreman' failed! Check the output for error!
--------------------------------------------------------------------------------
Scenario [Restore backup] failed.

The following steps ended up in failing state:

  [restore-installer-reset]

Resolve the failed steps and rerun
the command. In case the failures are false positives,
use --whitelist="restore-installer-reset"


Running Rescue Restore backup
================================================================================

[root@lxlabs0131 ~]# runuser -l postgres -c 'createdb foreman'
[root@lxlabs0131 ~]# foreman-maintain restore  /var/katello-backup-2022-07-22-22-25-52/
Running Restore backup
================================================================================
Check if command is run as root user:                                 [OK]
--------------------------------------------------------------------------------
Validate backup has appropriate files:                                [OK]
--------------------------------------------------------------------------------
Validate hostname is the same as backup:                              [OK]
--------------------------------------------------------------------------------
Validate network interfaces match the backup:                         [OK]
--------------------------------------------------------------------------------
Confirm dropping databases and running restore:

WARNING: This script will drop and restore your database.
Your existing installation will be replaced with the backup database.
Once this operation is complete there is no going back.
Do you want to proceed?, [y(yes), q(quit)] y
                                                                      [OK]
--------------------------------------------------------------------------------
Setting file security:
/ Restoring SELinux context                                           [OK]
--------------------------------------------------------------------------------
Restore configs from backup:
- Restoring configs                                                   [OK]
--------------------------------------------------------------------------------
Run installer reset:
- Installer reset                                                     [FAIL]
Failed executing yes | foreman-installer -v --reset-data --disable-system-checks , exit status 6:
 2022-07-25 09:26:17 [NOTICE] [root] Loading installer configuration. This will take some time.
2022-07-25 09:26:21 [NOTICE] [root] Running installer with log based terminal output at level NOTICE.
2022-07-25 09:26:21 [NOTICE] [root] Use -l to set the terminal output log level to ERROR, WARN, NOTICE, INFO, or DEBUG. See --full-help for definitions.
Are you sure you want to continue? This will drop the databases, reset all configurations that you have made and bring all application data back to a fresh install. [y/n]
2022-07-25 09:26:26 [NOTICE] [pre] Dropping foreman database!
2022-07-25 09:26:26 [NOTICE] [pre] Dropping candlepin database!
2022-07-25 09:26:26 [NOTICE] [pre] Dropping pulpcore database!
2022-07-25 09:26:27 [WARN  ] [pre] Pulpcore content directory not present at '/var/lib/pulp/docroot'
2022-07-25 09:26:27 [WARN  ] [pre] Skipping system checks.
2022-07-25 09:26:27 [WARN  ] [pre] Skipping system checks.
2022-07-25 09:26:38 [NOTICE] [configure] Starting system configuration.
2022-07-25 09:26:54 [NOTICE] [configure] 250 configuration steps out of 1364 steps complete.
2022-07-25 09:27:01 [NOTICE] [configure] 500 configuration steps out of 1366 steps complete.
2022-07-25 09:27:02 [ERROR ] [configure] Execution of '/bin/keytool -import -v -noprompt -storetype pkcs12 -keystore /etc/candlepin/certs/truststore -alias artemis-client -file /etc/foreman/client_cert.pem -storepass:file /etc/pki/katello/truststore_password-file -J-Dcom.redhat.fips=false' returned 1: keytool error: java.io.IOException: keystore password was incorrect
2022-07-25 09:27:02 [ERROR ] [configure] java.io.IOException: keystore password was incorrect
2022-07-25 09:27:02 [ERROR ] [configure] at sun.security.pkcs12.PKCS12KeyStore.engineLoad(PKCS12KeyStore.java:2079)
2022-07-25 09:27:02 [ERROR ] [configure] at java.security.KeyStore.load(KeyStore.java:1445)
2022-07-25 09:27:02 [ERROR ] [configure] at sun.security.tools.keytool.Main.doCommands(Main.java:836)
2022-07-25 09:27:02 [ERROR ] [configure] at sun.security.tools.keytool.Main.run(Main.java:377)
2022-07-25 09:27:02 [ERROR ] [configure] at sun.security.tools.keytool.Main.main(Main.java:370)
2022-07-25 09:27:02 [ERROR ] [configure] Caused by: java.security.UnrecoverableKeyException: failed to decrypt safe contents entry: javax.crypto.BadPaddingException: Given final block not properly padded. Such issues can arise if a bad key is used during decryption.
2022-07-25 09:27:02 [ERROR ] [configure] ... 5 more
2022-07-25 09:27:02 [ERROR ] [configure] /Stage[main]/Certs::Candlepin/Truststore_certificate[/etc/candlepin/certs/truststore:artemis-client]/ensure: change from 'absent' to 'present' failed: Execution of '/bin/keytool -import -v -noprompt -storetype pkcs12 -keystore /etc/candlepin/certs/truststore -alias artemis-client -file /etc/foreman/client_cert.pem -storepass:file /etc/pki/katello/truststore_password-file -J-Dcom.redhat.fips=false' returned 1: keytool error: java.io.IOException: keystore password was incorrect
2022-07-25 09:27:02 [ERROR ] [configure] java.io.IOException: keystore password was incorrect
2022-07-25 09:27:02 [ERROR ] [configure] at sun.security.pkcs12.PKCS12KeyStore.engineLoad(PKCS12KeyStore.java:2079)
2022-07-25 09:27:02 [ERROR ] [configure] at java.security.KeyStore.load(KeyStore.java:1445)
2022-07-25 09:27:02 [ERROR ] [configure] at sun.security.tools.keytool.Main.doCommands(Main.java:836)
2022-07-25 09:27:02 [ERROR ] [configure] at sun.security.tools.keytool.Main.run(Main.java:377)
2022-07-25 09:27:02 [ERROR ] [configure] at sun.security.tools.keytool.Main.main(Main.java:370)
2022-07-25 09:27:02 [ERROR ] [configure] Caused by: java.security.UnrecoverableKeyException: failed to decrypt safe contents entry: javax.crypto.BadPaddingException: Given final block not properly padded. Such issues can arise if a bad key is used during decryption.
2022-07-25 09:27:02 [ERROR ] [configure] ... 5 more
2022-07-25 09:27:02 [ERROR ] [configure] /Stage[main]/Certs::Candlepin/Certs::Keypair[katello-default-ca]/Private_key[/etc/candlepin/certs/candlepin-ca.key]: Could not evaluate: Execution of '/bin/openssl rsa -in /root/ssl-build/katello-default-ca.key -passin file:/etc/pki/katello/private/katello-default-ca.pwd -text' returned 1: unable to load Private Key
2022-07-25 09:27:02 [ERROR ] [configure] 140077840291648:error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt:crypto/evp/evp_enc.c:643:
2022-07-25 09:27:02 [ERROR ] [configure] 140077840291648:error:23077074:PKCS12 routines:PKCS12_pbe_crypt:pkcs12 cipherfinal error:crypto/pkcs12/p12_decr.c:63:
2022-07-25 09:27:02 [ERROR ] [configure] 140077840291648:error:2306A075:PKCS12 routines:PKCS12_item_decrypt_d2i:pkcs12 pbe crypt error:crypto/pkcs12/p12_decr.c:94:
2022-07-25 09:27:02 [ERROR ] [configure] 140077840291648:error:0907B00D:PEM routines:PEM_read_bio_PrivateKey:ASN1 lib:crypto/pem/pem_pkey.c:88:
2022-07-25 09:27:02 [ERROR ] [configure] Failed to add certificate to keystore: Execution of '/bin/keytool -importkeystore -noprompt -srckeystore /tmp/temp_keystore20220725-93372-7vb7k0 -srcstorepass:file /etc/pki/katello/keystore_password-file -destkeystore /etc/candlepin/certs/keystore -deststorepass:file /etc/pki/katello/keystore_password-file -srcalias tomcat -destalias tomcat -J-Dcom.redhat.fips=false' returned 1: Importing keystore /tmp/temp_keystore20220725-93372-7vb7k0 to /etc/candlepin/certs/keystore...
2022-07-25 09:27:02 [ERROR ] [configure] keytool error: java.io.IOException: keystore password was incorrect
2022-07-25 09:27:03 [ERROR ] [configure] Execution of '/bin/keytool -import -v -noprompt -storetype pkcs12 -keystore /etc/candlepin/certs/truststore -alias candlepin-ca -file /etc/candlepin/certs/candlepin-ca.crt -storepass:file /etc/pki/katello/truststore_password-file -J-Dcom.redhat.fips=false' returned 1: keytool error: java.io.IOException: keystore password was incorrect
2022-07-25 09:27:03 [ERROR ] [configure] java.io.IOException: keystore password was incorrect
2022-07-25 09:27:03 [ERROR ] [configure] at sun.security.pkcs12.PKCS12KeyStore.engineLoad(PKCS12KeyStore.java:2079)
2022-07-25 09:27:03 [ERROR ] [configure] at java.security.KeyStore.load(KeyStore.java:1445)
2022-07-25 09:27:03 [ERROR ] [configure] at sun.security.tools.keytool.Main.doCommands(Main.java:836)
2022-07-25 09:27:03 [ERROR ] [configure] at sun.security.tools.keytool.Main.run(Main.java:377)
2022-07-25 09:27:03 [ERROR ] [configure] at sun.security.tools.keytool.Main.main(Main.java:370)
2022-07-25 09:27:03 [ERROR ] [configure] Caused by: java.security.UnrecoverableKeyException: failed to decrypt safe contents entry: javax.crypto.BadPaddingException: Given final block not properly padded. Such issues can arise if a bad key is used during decryption.
2022-07-25 09:27:03 [ERROR ] [configure] ... 5 more
2022-07-25 09:27:03 [ERROR ] [configure] /Stage[main]/Certs::Candlepin/Truststore_certificate[/etc/candlepin/certs/truststore:candlepin-ca]/ensure: change from 'absent' to 'present' failed: Execution of '/bin/keytool -import -v -noprompt -storetype pkcs12 -keystore /etc/candlepin/certs/truststore -alias candlepin-ca -file /etc/candlepin/certs/candlepin-ca.crt -storepass:file /etc/pki/katello/truststore_password-file -J-Dcom.redhat.fips=false' returned 1: keytool error: java.io.IOException: keystore password was incorrect
2022-07-25 09:27:03 [ERROR ] [configure] java.io.IOException: keystore password was incorrect
2022-07-25 09:27:03 [ERROR ] [configure] at sun.security.pkcs12.PKCS12KeyStore.engineLoad(PKCS12KeyStore.java:2079)
2022-07-25 09:27:03 [ERROR ] [configure] at java.security.KeyStore.load(KeyStore.java:1445)
2022-07-25 09:27:03 [ERROR ] [configure] at sun.security.tools.keytool.Main.doCommands(Main.java:836)
2022-07-25 09:27:03 [ERROR ] [configure] at sun.security.tools.keytool.Main.run(Main.java:377)
2022-07-25 09:27:03 [ERROR ] [configure] at sun.security.tools.keytool.Main.main(Main.java:370)
2022-07-25 09:27:03 [ERROR ] [configure] Caused by: java.security.UnrecoverableKeyException: failed to decrypt safe contents entry: javax.crypto.BadPaddingException: Given final block not properly padded. Such issues can arise if a bad key is used during decryption.
2022-07-25 09:27:03 [ERROR ] [configure] ... 5 more
2022-07-25 09:27:08 [NOTICE] [configure] 750 configuration steps out of 1371 steps complete.
2022-07-25 09:27:09 [NOTICE] [configure] 1000 configuration steps out of 1380 steps complete.
2022-07-25 09:27:42 [NOTICE] [configure] 1250 configuration steps out of 1380 steps complete.
2022-07-25 09:29:07 [NOTICE] [configure] System configuration has finished.

  There were errors detected during install.
  Please address the errors and re-run the installer to ensure the system is properly configured.
  Failing to do so is likely to result in broken functionality.

  The full log is at /var/log/foreman-installer/katello.log
--------------------------------------------------------------------------------
Scenario [Restore backup] failed.

The following steps ended up in failing state:

  [restore-installer-reset]

Resolve the failed steps and rerun
the command. In case the failures are false positives,
use --whitelist="restore-installer-reset"



Running Rescue Restore backup
================================================================================

Hi, any news on this? I came across the same issue when running a foreman-maintain restore
Foreman version 3.3.1 Katello 4.5.0-1. (Migrate from RHEL7.9 to RHEL8.6)

The key files from the backup will be overwritten with old passwords during the run (at least these three)

/etc/pki/katello/truststore_password-file
/etc/pki/katello/private/katello-default-ca.pwd
/etc/pki/katello/keystore_password-file

If I am overwriting these files with the right values I end up with a foreman-rake db:migrate error:

foreman-rake db:migrate --trace --verbose                                                                                                                           :(
** Invoke db:migrate (first_time)
** Invoke db:load_config (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:load_config
** Invoke plugin:refresh_migrations (first_time)
** Invoke environment                                                                                                                                                                       ** Execute plugin:refresh_migrations
** Execute db:migrate
== 20220110223754 UpdateDisconnectedSettings: migrating =======================                                                                                                             rake aborted!                                                                                                                                                                               StandardError: An error has occurred, this and all later migrations canceled:

The single-table inheritance mechanism failed to locate the subclass: 'Setting::Content'. This error is raised because the column 'category' is reserved for storing the class in case of in
heritance. Please rename this column if you didn't intend it to be used for storing the inheritance class or overwrite Setting.inheritance_column to use another column for that information

Any help is greatly appreciated.

I am running into the same issue. Migrating from CentOS 7.9 to Rocky 8.

After it failed the first time I could see the keystore password files having a timestamp of “now” and are not identical to the ones from the old installation.

I’m re-running the restore right now with the suggested option --whitelist=“restore-installer-reset”. As expected, it skipped the “Run installer reset” stage and went strainht to “Stop applicable services” and now its restoring pulp data.

Gonna update this post when it has finished or failed.

Ok, unfortunately, after processing the pulp data it tried to update the installer and failed with the same keystore errors.

I looked at the /etc/pki/katello directory while the pulp data was processed, and it looked like this:

-rw-r--r--. 1 root      root    4634 Nov 13  2020 foreman.example.com-qpid-broker.pfx
drwxr-xr-x. 2 root      foreman  183 Oct 16 12:00 certs
-r--r-----. 1 root      tomcat    32 Nov 13  2020 keystore_password-file
-rw-r-----. 1 root      qpidd     32 Oct 20  2021 nss_db_password-file
drwxr-x---. 2 root      qpidd     54 Oct 20  2021 nssdb
drwxr-x---. 2 root      foreman  182 Oct 16 11:49 private
drwxr-x---. 2 root      redis     84 Nov 13  2020 puppet
-rw-r-----. 1 qdrouterd root    8268 Jun  1  2021 qpid_router_client.crt
-r--r-----. 1 qdrouterd root    3243 Jun  1  2021 qpid_router_client.key
-rw-r-----. 1 qdrouterd root    8276 Nov 13  2020 qpid_router_server.crt
-r--r-----. 1 qdrouterd root    3247 Nov 13  2020 qpid_router_server.key
-r--r-----. 1 root      tomcat    32 Nov 13  2020 truststore_password-file

This is clearly the correct password files from the restore.

When the task “installer update” is run, the directory gets replaced with:

-rw-r--r--. 1 root      root    4634 Nov 13  2020 foreman.example.com-qpid-broker.pfx
drwxr-xr-x. 2 root      foreman  183 Oct 16 12:00 certs
-r--r-----. 1 root      tomcat    32 Oct 21 14:23 keystore_password-file
-rw-r-----. 1 root      qpidd     32 Oct 21 14:23 nss_db_password-file
drwxr-x---. 2 root      qpidd     55 Oct 21 14:23 nssdb
drwxr-x---. 2 root      foreman  182 Oct 21 14:23 private
drwxr-x---. 2 root      redis     84 Nov 13  2020 puppet
-rw-r-----. 1 qdrouterd root    8268 Jun  1  2021 qpid_router_client.crt
-r--r-----. 1 qdrouterd root    3243 Jun  1  2021 qpid_router_client.key
-rw-r-----. 1 qdrouterd root    8276 Nov 13  2020 qpid_router_server.crt
-r--r-----. 1 qdrouterd root    3247 Nov 13  2020 qpid_router_server.key
-r--r-----. 1 root      tomcat    32 Oct 21 14:23 truststore_password-file

I don’t know why all the password files have a new timestamp and also different content.

I need to ping @katello here, sorry for that. But I have no idea on how to proceed.

The wrong passwords also get added to the tomcat configuration during installer-reset:

[root@foreman conf]# grep Pass server.xml
               keystorePass="pvPgp..."
               truststorePass="S3di..."
[root@foreman conf]# grep Pass /root/old/etc/tomcat/server.xml
               keystorePass="qENq..."
               truststorePass="y9x3..."

Right now I am trying to keep those files from getting overridden during the time the installer-reset runs, buts its a wild goose chase.

Copy this directory /opt/puppetlabs/puppet/cache/foreman_cache_data from your old to your new foreman. Then the restore worked for me.
I tried to delete this directory, but it will be recreated with some random passwords, which did not work.

1 Like

I took a slightly different approach, but yours is definitely preferable. I also managed to work around the issue and the F/K server plus proxy are back in business.

However, I do still believe this is something the devs should look into, if it hasn’t been solved already by a higher version of F/K.

Same happens for me:

[root@or ~]# foreman-rake db:migrate
Rubocop not loaded.
Rubocop not loaded.
Rubocop not loaded.
== 20220110223754 UpdateDisconnectedSettings: migrating =======================
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:The single-table inheritance mechanism failed to locate the subclass: 'Setting::Content'. This error is raised because the column 'category' is reserved for storing the class in case of inheritance. Please rename this column if you didn't intend it to be used for storing the inheritance class or overwrite Setting.inheritance_column to use another column for that information.
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/inheritance.rb:234:in `rescue in find_sti_class'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/inheritance.rb:227:in `find_sti_class'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/inheritance.rb:215:in `discriminate_class_for_record'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/persistence.rb:257:in `instantiate'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/querying.rb:58:in `block (2 levels) in find_by_sql'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/result.rb:62:in `block in each'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/result.rb:62:in `each'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/result.rb:62:in `each'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/querying.rb:58:in `map'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/querying.rb:58:in `block in find_by_sql'
/usr/share/gems/gems/activesupport-6.0.6.1/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/querying.rb:56:in `find_by_sql'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/relation.rb:824:in `block in exec_queries'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/relation.rb:842:in `skip_query_cache_if_necessary'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/relation.rb:811:in `exec_queries'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/relation.rb:626:in `load'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/relation.rb:250:in `records'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/relation/finder_methods.rb:499:in `find_take'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/relation/finder_methods.rb:98:in `take'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/relation/finder_methods.rb:81:in `find_by'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/querying.rb:21:in `find_by'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/core.rb:193:in `find_by'
/usr/share/gems/gems/katello-4.5.1/db/migrate/20220110223754_update_disconnected_settings.rb:3:in `up'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:831:in `exec_migration'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:812:in `block (2 levels) in migrate'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:811:in `block in migrate'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:471:in `with_connection'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:810:in `migrate'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:1002:in `migrate'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:1310:in `block in execute_migration_in_transaction'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:1361:in `block in ddl_transaction'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in `block in transaction'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/connection_adapters/abstract/transaction.rb:280:in `block in within_new_transaction'
/usr/share/gems/gems/activesupport-6.0.6.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize'
/usr/share/gems/gems/activesupport-6.0.6.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
/usr/share/gems/gems/activesupport-6.0.6.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
/usr/share/gems/gems/activesupport-6.0.6.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
/usr/share/gems/gems/activesupport-6.0.6.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/connection_adapters/abstract/transaction.rb:278:in `within_new_transaction'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in `transaction'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/transactions.rb:212:in `transaction'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:1361:in `ddl_transaction'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:1309:in `execute_migration_in_transaction'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:1281:in `block in migrate_without_lock'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:1280:in `each'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:1280:in `migrate_without_lock'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:1229:in `block in migrate'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:1382:in `with_advisory_lock'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:1229:in `migrate'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:1061:in `up'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:1036:in `migrate'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/tasks/database_tasks.rb:238:in `migrate'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/railties/databases.rake:86:in `block (3 levels) in <top (required)>'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/railties/databases.rake:84:in `each'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/railties/databases.rake:84:in `block (2 levels) in <top (required)>'
/usr/share/gems/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'Caused by:
ActiveRecord::SubclassNotFound: The single-table inheritance mechanism failed to locate the subclass: 'Setting::Content'. This error is raised because the column 'category' is reserved for storing the class in case of inheritance. Please rename this column if you didn't intend it to be used for storing the inheritance class or overwrite Setting.inheritance_column to use another column for that information.
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/inheritance.rb:234:in `rescue in find_sti_class'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/inheritance.rb:227:in `find_sti_class'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/inheritance.rb:215:in `discriminate_class_for_record'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/persistence.rb:257:in `instantiate'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/querying.rb:58:in `block (2 levels) in find_by_sql'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/result.rb:62:in `block in each'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/result.rb:62:in `each'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/result.rb:62:in `each'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/querying.rb:58:in `map'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/querying.rb:58:in `block in find_by_sql'
/usr/share/gems/gems/activesupport-6.0.6.1/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/querying.rb:56:in `find_by_sql'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/relation.rb:824:in `block in exec_queries'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/relation.rb:842:in `skip_query_cache_if_necessary'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/relation.rb:811:in `exec_queries'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/relation.rb:626:in `load'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/relation.rb:250:in `records'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/relation/finder_methods.rb:499:in `find_take'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/relation/finder_methods.rb:98:in `take'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/relation/finder_methods.rb:81:in `find_by'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/querying.rb:21:in `find_by'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/core.rb:193:in `find_by'
/usr/share/gems/gems/katello-4.5.1/db/migrate/20220110223754_update_disconnected_settings.rb:3:in `up'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:831:in `exec_migration'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:812:in `block (2 levels) in migrate'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:811:in `block in migrate'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:471:in `with_connection'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:810:in `migrate'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:1002:in `migrate'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:1310:in `block in execute_migration_in_transaction'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:1361:in `block in ddl_transaction'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in `block in transaction'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/connection_adapters/abstract/transaction.rb:280:in `block in within_new_transaction'
/usr/share/gems/gems/activesupport-6.0.6.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize'
/usr/share/gems/gems/activesupport-6.0.6.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
/usr/share/gems/gems/activesupport-6.0.6.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
/usr/share/gems/gems/activesupport-6.0.6.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
/usr/share/gems/gems/activesupport-6.0.6.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/connection_adapters/abstract/transaction.rb:278:in `within_new_transaction'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in `transaction'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/transactions.rb:212:in `transaction'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:1361:in `ddl_transaction'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:1309:in `execute_migration_in_transaction'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:1281:in `block in migrate_without_lock'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:1280:in `each'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:1280:in `migrate_without_lock'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:1229:in `block in migrate'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:1382:in `with_advisory_lock'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:1229:in `migrate'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:1061:in `up'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:1036:in `migrate'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/tasks/database_tasks.rb:238:in `migrate'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/railties/databases.rake:86:in `block (3 levels) in <top (required)>'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/railties/databases.rake:84:in `each'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/railties/databases.rake:84:in `block (2 levels) in <top (required)>'
/usr/share/gems/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'Caused by:
NameError: uninitialized constant Setting::Content
/usr/share/gems/gems/activesupport-6.0.6.1/lib/active_support/inflector/methods.rb:284:in `const_get'
/usr/share/gems/gems/activesupport-6.0.6.1/lib/active_support/inflector/methods.rb:284:in `block in constantize'
/usr/share/gems/gems/activesupport-6.0.6.1/lib/active_support/inflector/methods.rb:280:in `each'
/usr/share/gems/gems/activesupport-6.0.6.1/lib/active_support/inflector/methods.rb:280:in `inject'
/usr/share/gems/gems/activesupport-6.0.6.1/lib/active_support/inflector/methods.rb:280:in `constantize'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/inheritance.rb:229:in `find_sti_class'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/inheritance.rb:215:in `discriminate_class_for_record'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/persistence.rb:257:in `instantiate'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/querying.rb:58:in `block (2 levels) in find_by_sql'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/result.rb:62:in `block in each'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/result.rb:62:in `each'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/result.rb:62:in `each'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/querying.rb:58:in `map'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/querying.rb:58:in `block in find_by_sql'
/usr/share/gems/gems/activesupport-6.0.6.1/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/querying.rb:56:in `find_by_sql'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/relation.rb:824:in `block in exec_queries'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/relation.rb:842:in `skip_query_cache_if_necessary'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/relation.rb:811:in `exec_queries'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/relation.rb:626:in `load'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/relation.rb:250:in `records'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/relation/finder_methods.rb:499:in `find_take'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/relation/finder_methods.rb:98:in `take'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/relation/finder_methods.rb:81:in `find_by'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/querying.rb:21:in `find_by'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/core.rb:193:in `find_by'
/usr/share/gems/gems/katello-4.5.1/db/migrate/20220110223754_update_disconnected_settings.rb:3:in `up'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:831:in `exec_migration'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:812:in `block (2 levels) in migrate'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:811:in `block in migrate'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:471:in `with_connection'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:810:in `migrate'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:1002:in `migrate'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:1310:in `block in execute_migration_in_transaction'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:1361:in `block in ddl_transaction'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in `block in transaction'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/connection_adapters/abstract/transaction.rb:280:in `block in within_new_transaction'
/usr/share/gems/gems/activesupport-6.0.6.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize'
/usr/share/gems/gems/activesupport-6.0.6.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
/usr/share/gems/gems/activesupport-6.0.6.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
/usr/share/gems/gems/activesupport-6.0.6.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
/usr/share/gems/gems/activesupport-6.0.6.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/connection_adapters/abstract/transaction.rb:278:in `within_new_transaction'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in `transaction'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/transactions.rb:212:in `transaction'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:1361:in `ddl_transaction'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:1309:in `execute_migration_in_transaction'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:1281:in `block in migrate_without_lock'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:1280:in `each'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:1280:in `migrate_without_lock'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:1229:in `block in migrate'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:1382:in `with_advisory_lock'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:1229:in `migrate'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:1061:in `up'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/migration.rb:1036:in `migrate'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/tasks/database_tasks.rb:238:in `migrate'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/railties/databases.rake:86:in `block (3 levels) in <top (required)>'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/railties/databases.rake:84:in `each'
/usr/share/gems/gems/activerecord-6.0.6.1/lib/active_record/railties/databases.rake:84:in `block (2 levels) in <top (required)>'
/usr/share/gems/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

This line fails: katello/20220110223754_update_disconnected_settings.rb at master · Katello/katello · GitHub
Because it would try to use Setting::Content which would result in:
The single-table inheritance mechanism failed to locate the subclass: ‘Setting::Content’
Therefore, I think the order of the db migrations is wrong.

The 20220110* would run BEFORE 20220419* but the code change was already done in foreman/katello. Therefore Setting.find(:content…) fails.

I’m currently on a broken system, because Setting with category Setting::Content exists, especially the Setting with the name “content_disconnected” and it tries to run the migration 20220110223754_update_disconnected_settings.rb but this is not possible.

Fix: Fixes #36343 - Fix migration failure by sbernhard · Pull Request #10540 · Katello/katello · GitHub