Bug 1651389
Summary: | Red Hat Satellite 6.4 upgrade fails with error Validation failed: Name has already been taken at db:migrate stage | ||
---|---|---|---|
Product: | Red Hat Satellite | Reporter: | Rajan Gupta <rajgupta> |
Component: | Users & Roles | Assignee: | Kavita <kgaikwad> |
Status: | CLOSED ERRATA | QA Contact: | Radovan Drazny <rdrazny> |
Severity: | high | Docs Contact: | |
Priority: | unspecified | ||
Version: | 6.4.0 | CC: | ahumbe, anerurka, apatel, a.r.welter, bshephar, dhlavacd, greartes, gscarbor, hmore, imntreal, inecas, kgaikwad, kkinge, ktordeur, mbacovsk, mcorr, mhulan, mmccune, mverma, ptrivedi, rajgupta, rankumar, saydas, vmeghana |
Target Milestone: | 6.6.0 | Keywords: | PrioBumpGSS, Triaged, Upgrades |
Target Release: | Unused | ||
Hardware: | All | ||
OS: | All | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | If docs needed, set a value | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2019-10-22 12:46:44 UTC | Type: | Bug |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
Rajan Gupta
2018-11-19 21:41:05 UTC
Could we get the full log or output for "foreman-rake db:migrate" please? Since not everyone hit this issue, the reproducer or DB export would also help. Pending workaround: Step 1: Find out the duplicate roles using foreman-rake Role.select("COUNT(name) as total, name") .group(:name).having("COUNT(name) > 1").order(:name).map{|p| {p.name => p.total} } => [{"Discovery Manager"=>2}] Step 2: Rename the duplicate Record cat <<FIX | foreman-rake console role_name = 'Discovery Manager' r = Role.find_by_name(role_name) r.builtin = 2 r.name = 'Duplicate ' + role_name r.save!(validate: false) FIX Try to upgrade the Satellite The commands were a little confusing for me because of the formatting. This is what I ran that worked for me for discovering the duplicate roles: > printf 'Role.select("COUNT(name) as total, name").group(:name).having("COUNT(name) > 1").order(:name).map{|p| {p.name => p.total} }\n' | foreman-rake console From that, I got: > => [{"Discovery Manager"=>3}, {"Remote Execution Manager"=>2}, {"Remote Execution User"=>2}] I then ran these series of commands to rename the duplicates: > cat <<FIX | foreman-rake console > role_name = 'Discovery Manager' > r = Role.find_by_name(role_name) > r.builtin = 2 > r.name = 'Duplicate 1' + role_name > r.save!(validate: false) > FIX > > cat <<FIX | foreman-rake console > role_name = 'Discovery Manager' > r = Role.find_by_name(role_name) > r.builtin = 2 > r.name = 'Duplicate 2' + role_name > r.save!(validate: false) > FIX > > cat <<FIX | foreman-rake console > role_name = 'Remote Execution Manager' > r = Role.find_by_name(role_name) > r.builtin = 2 > r.name = 'Duplicate ' + role_name > r.save!(validate: false) > FIX > > cat <<FIX | foreman-rake console > role_name = 'Remote Execution User' > r = Role.find_by_name(role_name) > r.builtin = 2 > r.name = 'Duplicate ' + role_name > r.save!(validate: false) > FIX I'm taking another shot at my upgrade, now. That did the trick for me. I've hit the same issue with my Satellite upgrade from 6.4 to 6.5. Run the steps mentioned in #12, which progressed it, but now getting: Caused by: ActiveRecord::InvalidForeignKey: PG::ForeignKeyViolation: ERROR: update or delete on table "katello_contents" violates foreign key constraint "katello_produ ct_content_content_id_fk" on table "katello_product_contents" DETAIL: Key (id)=(2636) is still referenced from table "katello_product_contents". : DELETE FROM "katello_contents" WHERE "katello_contents"."id" = $1 Steps: 1. foreman-maintain upgrade run 2. upgrade broke, run the steps from #12 3. foreman-maintain upgrade run --target-version 6.5 --whitelist="disk-performance,hammer-setup,hammer-ping" ( Need to now skip the hammer steps because everything is broken ) 4. Breaks with the foreign key constraint error above. The services seem to be running with katello-service status, but the webui has the old: Service unavailable ERF64-6496 [Foreman::MaintenanceException]: There are migrations pending in the system. This is my home satellite server. So I'm happy to experiment with anything you want, or provide any info if you feel this is relevant to the same issue. Mine might actually be this: https://access.redhat.com/solutions/4156421 I didn't check if there was a new 6.4.z available before I did --target-version 6.5. We can ignore my issue, it's probably not related to the original failure. Created redmine issue https://projects.theforeman.org/issues/27247 from this bug Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHSA-2019:3172 |