Bug 1612909
Summary: | Concurrent creation of subnets can lead to records with duplicate names | ||
---|---|---|---|
Product: | Red Hat Satellite | Reporter: | Ivan Necas <inecas> |
Component: | Networking | Assignee: | Ivan Necas <inecas> |
Status: | CLOSED ERRATA | QA Contact: | Jitendra Yejare <jyejare> |
Severity: | high | Docs Contact: | |
Priority: | unspecified | ||
Version: | 6.3.2 | CC: | andrew.schofield, egolov, inecas, jyejare, omankame, simeon.hoch, sthirugn |
Target Milestone: | 6.4.0 | Keywords: | Triaged |
Target Release: | Unused | ||
Hardware: | Unspecified | ||
OS: | Unspecified | ||
Whiteboard: | |||
Fixed In Version: | foreman-1.18.0.20-1 | Doc Type: | If docs needed, set a value |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2018-10-16 19:02:08 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
Ivan Necas
2018-08-06 13:59:43 UTC
Created redmine issue https://projects.theforeman.org/issues/24546 from this bug Here is the cleanup script to merge the duplicate subnet records: cat <<EOF | foreman-rake console duplicate_names = Subnet.unscoped.select(:name).group(:name).having('count(name) > 1').pluck(:name) Rails.logger.info("Found #{duplicate_names} duplicate subnet names.") duplicate_names.each do |name| winner, *loosers = Subnet.unscoped.where(name: name) Rails.logger.info("Merging duplicate subnets with name '#{name}', " \ "keeping #{winner.id}, merging with #{loosers.map(&:id)}") Hostgroup.unscoped.where(:subnet_id => loosers.map(&:id)).update_all(:subnet_id => winner.id) Nic::Base.unscoped.where(:subnet_id => loosers.map(&:id)).update_all(:subnet_id => winner.id) SubnetParameter.unscoped.where(:reference_id => loosers.map(&:id)).update_all(:reference_id => winner.id) loosers.each(&:destroy!) end EOF Upstream bug assigned to inecas Upstream bug assigned to inecas Moving this bug to POST for triage into Satellite 6 since the upstream issue https://projects.theforeman.org/issues/24546 has been resolved. Verified! @ Satellite 6.4 snap 21 Steps: 1. Run API command to create concurrent subnets with same name(using the same script mentioned in Description of this bug) Observation: 1. The concurrent subnets are created but not duplicates. 2. An error is returned on attempting to create duplicate subnet as: "error": {"id":null,"errors":{"name":["has already been taken"]},"full_messages":["Name has already been taken"]} Hence the bug is now verified. Also, I observed sometimes the incorrect/db error is redirected while cresting duplicate subnets concurrently as: "error": {"message":"PG::UniqueViolation: ERROR: duplicate key value violates unique constraint \"index_subnets_on_name\"\nDETAIL: Key (name)=(bug_subnet-19) already exists.\n: INSERT INTO \"subnets\" (\"network\", \"mask\", \"name\", \"created_at\", \"updated_at\") VALUES ($1, $2, $3, $4, $5) RETURNING \"id\""} I would raise another bz for same. 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-2018:2927 |