Project

General

Profile

Actions

Bug #32657

closed

Upgrade fails with error Validation failed: Name has already been taken at db:seed stage

Added by Tomer Brisker almost 3 years ago. Updated almost 3 years ago.

Status:
Closed
Priority:
High
Assignee:
Category:
Templates
Target version:
-
Difficulty:
Triaged:
No
Fixed in Releases:
Found in Releases:

Description

Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1954021

Description of problem:

Red Hat Satellite 6.8 minor upgrade fails with error Validation failed: Name has already been taken at db:migrate state

Version-Release number of selected component (if applicable):

6.8.z

Steps to Reproduce:

=> Execute the command to do a minor update

  1. satellite-maintain upgrade run --target-version 6.8.z

Actual results:

=> The satellite installer fails with the below error:-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2021-04-27 00:15:44 [ERROR ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:seed]/Exec[foreman-rake-db:seed]: Failed to call refresh: '/usr/sbin/foreman-rake db:seed' returned 1 instead of one of [0]
2021-04-27 00:15:44 [ERROR ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:seed]/Exec[foreman-rake-db:seed]: '/usr/sbin/foreman-rake db:seed' returned 1 instead of one of [0]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expected results:

The upgrade should be completed.

Additional info:

The issue seems to be with duplicate templete.

Workaround to fix the issue:- ============================
=> Execute the query to list the templates:-

  1. su - postgres -c "echo \"SELECT a.* FROM templates a JOIN (SELECT name, COUNT() FROM templates GROUP BY name HAVING count() > 1 ) b ON a.name = b.name ORDER BY a.name;\" | psql foreman"

=> Identify the duplicate template:-

  1. awk F\| '{print $1, $2, $8, $11, $6}' '/home/sadas/Downloads/foreman.txt' | grep "\S"
    id name locked type created_at
    ----
    ---------------------------------------------------------------------------------+
    297 Host - Last Checkin t ReportTemplate 2021-04-26 21:03:44.527975 ===> The issue seems to be with these duplicate templates(id 297 and 296).
    296 Host - Last Checkin t ReportTemplate 2021-04-26 21:03:44.508732
    59 Jumpstart default t Ptable 2017-08-08 07:47:49.520343
    21 Jumpstart default t ProvisioningTemplate 2017-08-08 07:47:48.798974
    61 Kickstart default t Ptable 2017-08-08 07:47:49.549152
    206 Kickstart default t ProvisioningTemplate 2020-01-29 09:00:56.526946
    30 Preseed default t ProvisioningTemplate 2017-08-08 07:47:48.945963
    62 Preseed default t Ptable 2017-08-08 07:47:49.563543
    ------------+--------------------+----------------------------+-------------------------+
    => Execute the command to unlock the template:- // Take a snapshot only then proceed with the next steps.
  1. su - postgres -c "echo \"update templates set locked = 'f' where id='297';\" | psql foreman"

=> Run the following and verify the output shows one of the entities of "Host - Last Checkin"

  1. su - postgres -c "echo \"select id, name, type from templates where id='297';\" | psql foreman"

If looks okay, then rename the duplicate using the below query:-

  1. su - postgres -c "echo \"update templates set name = 'Host - Last Checkin 2' where id='297';\" | psql foreman"

Following should now have named as "Host - Last Checkin 2"

  1. su - postgres -c "echo \"select id, name, type from templates where id='297';\" | psql foreman"

Then rerun the satellite-installer to complete the minor update.


Related issues 1 (0 open1 closed)

Related to Foreman - Bug #32086: db seed triggered by sidekiq resulting in duplicate provisioning-templatesClosedActions
Actions

Also available in: Atom PDF