Project

General

Profile

Actions

Bug #14689

closed

ActiveRecord::RecordInvalid: Validation failed: Name has already been taken

Added by Zach McNeilly almost 8 years ago. Updated almost 8 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Foreman Integration
Target version:
-
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

Using the salt smart proxy and salt plugin, I deleted a host from Foreman, destroyed the VM, created a new VM with the same name, and tried to use "foreman-node" to update the facts for the new host. I received the error "ActiveRecord::RecordInvalid: Validation failed: Name has already been taken" in production.log when I tried to do this.

I spoke with stbenjam on IRC and he suggested I make the following change to /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_salt-5.0.0/app/services/foreman_salt/fact_importer.rb :

def fact_names
-@fact_names ||= fact_name_class.maximum(:id, :group => 'name')
+@fact_names ||= fact_name_class.group(:name).maximum(:id)
end

This seems to have fixed the problem for me.


Related issues 2 (0 open2 closed)

Related to Foreman - Bug #13819: Fact imports fail with: Validation failed: Fact name has already been takenClosedMarek Hulán02/20/2016Actions
Has duplicate Salt - Bug #15129: Errors in production.log when upload-salt-reports runs - katello 3.0 RC5, Foreman 1.11.2Duplicate05/23/2016Actions
Actions #1

Updated by Anonymous almost 8 years ago

  • Project changed from Foreman to Salt
  • Category set to Foreman Integration
Actions #2

Updated by Marek Hulán almost 8 years ago

  • Related to Bug #13819: Fact imports fail with: Validation failed: Fact name has already been taken added
Actions #3

Updated by Markus Gebert almost 8 years ago

I'm seeing this too with Foreman 1.11 and Foreman Salt 5.0.0. The fix mentioned by the OP seems to help so far.

Actions #4

Updated by Anonymous almost 8 years ago

  • Status changed from New to Closed
  • Assignee set to Anonymous

done in 1ceeece560af143bb90b211ef8404c18537e3519

Actions #5

Updated by Stephen Benjamin over 7 years ago

  • Has duplicate Bug #15129: Errors in production.log when upload-salt-reports runs - katello 3.0 RC5, Foreman 1.11.2 added
Actions

Also available in: Atom PDF