Getting '/usr/sbin/foreman-rake db:migrate' returned 1 instead of one of [0] ERROR while trying to upgrade Satellite to latest.
Environment
- Red Hat Satellite 6.11
- Red Hat Enterprise Linux 7/8
Issue
- Getting '/usr/sbin/foreman-rake db:migrate' returned 1 instead of one of [0] ERROR while trying to upgrade Satellite to latest.
2022-05-31 21:57:19 [NOTICE] [configure] 1500 configuration steps out of 2197 steps complete.
2022-05-31 22:04:32 [ERROR ] [configure] '/usr/sbin/foreman-rake db:migrate' returned 1 instead of one of [0]
2022-05-31 22:04:32 [ERROR ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]/returns: change from 'notrun' to ['0'] failed: '/usr/sbin/foreman-rake db:migrate' returned 1 instead of one of [0]
2022-05-31 22:05:23 [NOTICE] [configure] 1750 configuration steps out of 3001 steps complete.
..
..
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/satellite.log
Package versions are being locked.
[FAIL]
Failed executing LANG=en_US.utf-8 satellite-installer --disable-system-checks, exit status 6
--------------------------------------------------------------------------------
Scenario [Migration scripts to Satellite 6.11.z] failed.
Resolution
-
This issue was reported to the Red Hat Engineering team via Bugzilla This content is not included.2087727 and resolved with the latest
Satellite 6.11.zrelease. -
As workaround, rename the latest
*remove_duplicate_errata.rbfile on theSatelliteserver:FOR RHEL7
# rpm -qa tfm-rubygem-katello --last # check the latest installed tfm-rubygem-katello package version # ls -ldh /opt/theforeman/tfm/root/usr/share/gems/gems/katello* # ll /opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.1.57/db/migrate/20220303160220_remove_duplicate_errata.rb # mv /opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.1.57/db/migrate/20220303160220_remove_duplicate_errata.rb /opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.1.57/db/migrate/20220303160220_remove_duplicate_errata.rb_bakFor RHEL8
# rpm -qa rubygem-katello --last # check the latest installed rubygem-katello package version # ls -ldh /usr/share/gems/gems/katello* # ll /usr/share/gems/gems/katello-4.3.0.52/db/migrate/20220303160220_remove_duplicate_errata.rb # mv /usr/share/gems/gems/katello-4.3.0.52/db/migrate/20220303160220_remove_duplicate_errata.rb /usr/share/gems/gems/katello-4.3.0.52/db/migrate/20220303160220_remove_duplicate_errata.rb_bak -
Perform the
db:migratecommand manually and ensure that it is getting successfully completed.# foreman-rake db:migrate --trace --verbose -
Once
db:migrateis successful executed, Re-run the upgrade on theSatelliteserver.
Diagnostic Steps
-
The manual execution of
db:migratecommand shows the following error.For RHEL7
[root@satellite ~]# rpm -qa tfm-rubygem-katello --last tfm-rubygem-katello-4.1.1.57-1.el7sat.noarch Tue 31 May 2022 09:55:35 PM EDT [root@satellite ~]# ls -ldh /opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.1.57 drwxr-xr-x. 11 root root 138 May 31 21:55 /opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.1.57 [root@satellite ~]# ll /opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.1.57/db/migrate/20220303160220_remove_duplicate_errata.rb -rw-r--r--. 1 root root 3578 May 11 12:26 /opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.1.57/db/migrate/20220303160220_remove_duplicate_errata.rb [root@satellite ~]# foreman-rake db:migrate --trace --verbose 'ErbParser' is ignored. 'RubyParser' is ignored. ** 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 == 20220303160220 RemoveDuplicateErrata: migrating ============================ rake aborted! StandardError: An error has occurred, this and all later migrations canceled: PG::InFailedSqlTransaction: ERROR: current transaction is aborted, commands ignored until end of transaction block /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/postgresql_adapter.rb:675:in `async_exec_params' .. .. Caused by: PG::NotNullViolation: ERROR: null value in column "erratum_package_id" violates not-null constraint DETAIL: Failing row contains (7165, 401, null, 2021-08-14 06:11:55.054979, 2022-06-01 03:43:41.7733). /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/postgresql_adapter.rb:675:in `async_exec_params' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/postgresql_adapter.rb:675:in `block (2 levels) in exec_no_cache' /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport- 6.0.3.7/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads' .. .. /opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.1.57/db/migrate/20220303160220_remove_duplicate_errata.rb:41:in `block in up' /opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.1.57/db/migrate/20220303160220_remove_duplicate_errata.rb:20:in `each' /opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.1.57/db/migrate/20220303160220_remove_duplicate_errata.rb:20:in `up' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:831:in `exec_migration' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:812:in `block (2 levels) in migrate' /opt/rh/rh-ruby27/root/usr/share/ruby/benchmark.rb:293:in `measure' .. .. /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 `<main>' Tasks: TOP => db:migrate
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.