Project

General

Profile

Bug #5129

Host Group creation may fail if Host Group with id 1 exists with same parameter name

Added by Justin Sherrill almost 5 years ago. Updated 8 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Database
Target version:
Difficulty:
Triaged:
Bugzilla link:
Pull request:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

I believe the cause is similar to issue #4731. On a production RHEL or Centos install, when creating a Host Group and specifying some parameter, if a host group with ID = 1 already exists with that same parameter name the creation will fail with error "Name has already been taken". The cause is that when this validation is run:

validates :name, :uniqueness => {:scope => :reference_id}

The new parameter's reference_id is set to 1 instead of nil. Thus if a host group already exists with this parameter name (and that host group has an ID of 1), the validation will fail.

Here is an example of a validation:

GroupParameter Exists (0.2ms) SELECT 1 AS one FROM "parameters" WHERE "parameters"."type" IN ('GroupParameter') AND ("parameters"."name" = 'kt_org' AND "parameters"."reference_id" = 1) LIMIT 1

This was the sql generated with a new host group submission.

NOTE: this will not occur on a development install using the latest version of Rails 3.2.


Related issues

Related to Foreman - Bug #6375: Can't create parameters for operating system with id 1 using APIClosed2014-06-25

Associated revisions

Revision 691f0a1a (diff)
Added by Joseph Magen almost 5 years ago

fixes #5129 - Host Group creation may fail if parameter is same name

Revision 4a29b9eb (diff)
Added by Joseph Magen over 4 years ago

fixes #5129 - Host Group creation may fail if parameter is same name

(cherry picked from commit 691f0a1a809569d125e9385e60f8f1e1c8d88061)

History

#1 Updated by Dominic Cleal almost 5 years ago

  • Category set to Database
  • Status changed from New to Ready For Testing
  • Target version set to 1.8.4

#2 Updated by Dominic Cleal almost 5 years ago

  • Status changed from Ready For Testing to New
  • Target version deleted (1.8.4)

PR closed.

#3 Updated by Justin Sherrill almost 5 years ago

  • Bugzilla link set to https://bugzilla.redhat.com/show_bug.cgi?id=1103321

#4 Updated by Dominic Cleal almost 5 years ago

  • Status changed from New to Ready For Testing
  • Assignee set to Joseph Magen
  • Target version set to 1.8.1

#5 Updated by Dominic Cleal almost 5 years ago

  • Legacy Backlogs Release (now unused) set to 18

#6 Updated by Joseph Magen almost 5 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

#7 Updated by Dominic Cleal over 4 years ago

  • Related to Bug #6375: Can't create parameters for operating system with id 1 using API added

Also available in: Atom PDF