Project

General

Profile

Bug #6412

Trying to remove a DHCP record fails due to an invalid subnet check

Added by David Swift almost 5 years ago. Updated 11 months ago.

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

Description

Take three hosts, add them into foreman via API. Then try and remove them. The first deletes fine, but the subsequent deletions fail. The problem is in file , line 196. When the subnet gets searched, the 1st host is not found, and then the entire subnet array is returned to the delete function, which then throws an error.

Pull request coming.


Related issues

Has duplicate Smart Proxy - Bug #6311: Deleting a host and re-creating it generates a DHCP errorDuplicate2014-06-20

Associated revisions

Revision 57ea7e82 (diff)
Added by David Swift almost 5 years ago

Fixes #6412: Trying to remove a DHCP record fails due to an invalid subnet check

History

#1 Updated by Dominic Cleal almost 5 years ago

  • Category set to DHCP
  • Status changed from New to Ready For Testing
  • Assignee set to David Swift
  • Target version set to 1.8.1

#2 Updated by David Swift almost 5 years ago

Copying the description I just wrote into github, as it explains this behavior better:

A small correction - if it fails to find the DHCP record of a deleted host in the subnet under evaluation, it will not attempt to delete it from the subnet under evaluation. This allows it to carry on, and actually delete the record that is intended.

The problem arises due to the evaluation of DHCP records with a status of 'deleted'. These records are evaluated against the subnet that contains the actual host we want to delete, and if they are found, they are removed prior to executing the target deletion.

In the case that triggered this bug, the record with the DHCP deleted status was originally in a different subnet before it was removed. On a subsequent delete run for a second host, the previously deleted host could not be found in the subnet under evaluation, and line 198 never returned a value. This left the return value of find_record_by_hostname as the result of subnet.records.each (an array), which then caused the subnet.delete call to throw an error.

A better fix might be to track the subnets of hosts with a DHCP status of deleted, but this gets the job done without added complexity.

HTH.

#3 Updated by Dominic Cleal almost 5 years ago

  • Legacy Backlogs Release (now unused) set to 18

#4 Updated by Dominic Cleal almost 5 years ago

  • Has duplicate Bug #6311: Deleting a host and re-creating it generates a DHCP error added

#5 Updated by Dmitri Dolguikh almost 5 years ago

  • Target version changed from 1.8.1 to 1.8.0

#6 Updated by Bryan Kearney almost 5 years ago

  • Bugzilla link set to 1117837

#7 Updated by Anonymous almost 5 years ago

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

#8 Updated by Dominic Cleal almost 5 years ago

  • Project changed from Foreman to Smart Proxy
  • Category changed from DHCP to DHCP

Also available in: Atom PDF