Bug #5129

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

Added by Justin Sherrill over 3 years ago. Updated over 3 years ago.

Status:Closed
Priority:Normal
Assigned To:Joseph Magen
Category:Database
Target version:Sprint 25
Difficulty: Bugzilla link:1103321
Found in release: Pull request:
Story points-
Velocity based estimate-
Release1.5.2Release relationshipAuto

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 us... Closed 06/25/2014

Associated revisions

Revision 691f0a1a
Added by Joseph Magen over 3 years ago

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

Revision 4a29b9eb
Added by Joseph Magen over 3 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 over 3 years ago

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

#2 Updated by Dominic Cleal over 3 years ago

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

PR closed.

#3 Updated by Justin Sherrill over 3 years ago

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

#4 Updated by Dominic Cleal over 3 years ago

  • Status changed from New to Ready For Testing
  • Assigned To set to Joseph Magen
  • Target version set to Sprint 25

#5 Updated by Dominic Cleal over 3 years ago

  • Release set to 1.5.2

#6 Updated by Joseph Magen over 3 years ago

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

#7 Updated by Dominic Cleal over 3 years ago

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

Also available in: Atom PDF