Bug #6412

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

Added by David Swift over 3 years ago. Updated over 3 years ago.

Status:Closed
Priority:Normal
Assigned To:David Swift
Category:DHCP
Target version:Foreman - Sprint 26
Difficulty: Bugzilla link:1117837
Found in release: Pull request:
Story points-
Velocity based estimate-
Release1.5.2Release relationshipAuto

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

Duplicated by Smart Proxy - Bug #6311: Deleting a host and re-creating it generates a DHCP error Duplicate 06/20/2014

Associated revisions

Revision 57ea7e82
Added by David Swift over 3 years ago

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

History

#1 Updated by Dominic Cleal over 3 years ago

  • Category set to DHCP
  • Status changed from New to Ready For Testing
  • Assigned To set to David Swift
  • Target version set to Sprint 25

#2 Updated by David Swift over 3 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 over 3 years ago

  • Release set to 1.5.2

#4 Updated by Dominic Cleal over 3 years ago

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

#5 Updated by Dmitri Dolguikh over 3 years ago

  • Target version changed from Sprint 25 to Sprint 26

#6 Updated by Bryan Kearney over 3 years ago

  • Bugzilla link set to 1117837

#7 Updated by Anonymous over 3 years ago

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

#8 Updated by Dominic Cleal over 3 years ago

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

Also available in: Atom PDF