Project

General

Profile

Actions

Bug #19649

closed

DHCP lease prevents reservation creation with the same MAC/IP

Added by Lukas Zapletal over 7 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
DHCP
Target version:
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

This is Foreman Core 1.15 (develop):

  • Create a subnet with same lease and foreman IP ranges.
  • Have an active lease for particular MAC and IP.
  • Create new host and give it the same MAC address, select the Subnet and note that Foreman assigns the IP address from the lease. This is expected behavior if lease IP address falls into foreman IP range.
  • Submit leads to DHCP conflict.
 INFO  app : Started GET "/discovered_hosts/mac525400130513/edit?utf8=%E2%9C%93&host%5Bhostgroup_id%5D=4&host%5Borganization_id%5D=1&host%5Blocation_id%5D=2&quick_submit=Quick+Create" for 127.0.0.1 at 20
 INFO  app : Processing by DiscoveredHostsController#edit as HTML
 INFO  app :   Parameters: {"utf8"=>"✓", "host"=>{"hostgroup_id"=>"4", "organization_id"=>"1", "location_id"=>"2"}, "quick_submit"=>"Quick Create", "id"=>"mac525400130513"}
 INFO  app : Current user: admin (administrator)
DEBUG  app : Setting current user thread-local variable to admin
DEBUG  app : Setting current organization thread-local variable to none
DEBUG  app : Setting current location thread-local variable to none
DEBUG  app : Setting current organization thread-local variable to none
DEBUG  app : Setting current location thread-local variable to none
DEBUG  app : Comparing ["52:54:00:13:05:13", "192.168.122.6", "192.168.122.0"] == ["52:54:00:13:05:13", "192.168.122.6", "192.168.122.0"]
DEBUG  app : Comparing ["52:54:00:13:05:13", "192.168.122.6", "192.168.122.0"] == ["52:54:00:13:05:13", "192.168.122.6", "192.168.122.0"]
DEBUG  app : Detected a changed required for DHCP record
DEBUG  app : Enqueued task 'Create DHCP Settings for mac525400130513.local.lan' to 'Host::Managed Main' queue
DEBUG  app : Setting current organization thread-local variable to MyOrg
DEBUG  app : Setting current location thread-local variable to MyLoc
DEBUG  app : Setting current location thread-local variable to none
DEBUG  app : Setting current organization thread-local variable to none
DEBUG  app : Enqueued task 'Deploy TFTP PXEGrub2 config for mac525400130513.local.lan' to 'Host::Managed Main' queue
DEBUG  app : Enqueued task 'Deploy TFTP PXELinux config for mac525400130513.local.lan' to 'Host::Managed Main' queue
DEBUG  app : Enqueued task 'Deploy TFTP PXEGrub config for mac525400130513.local.lan' to 'Host::Managed Main' queue
DEBUG  app : Enqueued task 'Fetch TFTP boot files for mac525400130513.local.lan' to 'Host::Managed Main' queue
DEBUG  app : Enqueued task 'Rebooting mac525400130513.local.lan' to 'Host::Managed Post' queue
DEBUG  app : Processing task 'Create DHCP Settings for mac525400130513.local.lan' from 'Host::Managed Main'
 INFO  app : Create DHCP reservation mac525400130513.local.lan for mac525400130513.local.lan-52:54:00:13:05:13/192.168.122.6
DEBUG  app : DHCP reservation on net 192.168.122.0 with attrs: {:hostname=>"mac525400130513.local.lan", :mac=>"52:54:00:13:05:13", :ip=>"192.168.122.6", :network=>"192.168.122.0", :nextServer=>"192.168.1
 WARN  app : Create DHCP Settings for mac525400130513.local.lan task failed with the following error: ERF12-6899 [ProxyAPI::ProxyException]: Unable to set DHCP entry ([RestClient::Conflict]: 409 Conflict
ProxyAPI::ProxyException: ERF12-6899 [ProxyAPI::ProxyException]: Unable to set DHCP entry ([RestClient::Conflict]: 409 Conflict) for proxy http://localhost:8448/dhcp

I only had one lease as expected:

{
    "reservations": [

    ],
    "leases": [
        {
            "name": "*lease*",
            "ip": "192.168.122.6",
            "mac": "52:54:00:13:05:13",
            "subnet": "192.168.122.0/255.255.255.0",
            "starts": "2017-05-24 10:01:35 UTC",
            "ends": "2017-05-24 10:11:35 UTC",
            "state": "active",
            "cltt": "2017-05-24 10:01:35 UTC",
            "next_state": "free",
            "hardware_type": "ethernet" 
        }
    ]
}

On proxy it really treats it as a conflict:

W, [2017-05-24T12:06:08.245118 ]  WARN -- : Request to create a conflicting DHCP record
D, [2017-05-24T12:06:08.245220 ] DEBUG -- : request: #<Proxy::DHCP::Reservation:0x005577770bb410 @name="mac525400130513.local.lan", @subnet=#<Proxy::DHCP::Subnet:0x0055777631ba80 @network="192.168.122.0", @netmask="255.255.255.0", @ipaddr=#<IPAddr: IPv4:192.168.122.0/255.255.255.0>, @options={:routers=>["192.168.122.1"], :domain_name_servers=>["192.168.122.1"]}, @netmask_to_i=4294967040>, @ip="192.168.122.6", @mac="52:54:00:13:05:13", @options={"nextServer"=>"192.168.122.1", "filename"=>"pxelinux.0", "hostname"=>"mac525400130513.local.lan"}>
D, [2017-05-24T12:06:08.245314 ] DEBUG -- : existing: [#<Proxy::DHCP::Lease:0x0055777748dac0 @name="*lease*", @starts=2017-05-24 10:05:25 UTC, @ends=2017-05-24 10:15:25 UTC, @state="active", @subnet=#<Proxy::DHCP::Subnet:0x0055777631ba80 @network="192.168.122.0", @netmask="255.255.255.0", @ipaddr=#<IPAddr: IPv4:192.168.122.0/255.255.255.0>, @options={:routers=>["192.168.122.1"], :domain_name_servers=>["192.168.122.1"]}, @netmask_to_i=4294967040>, @ip="192.168.122.6", @mac="52:54:00:13:05:13", @options={:cltt=>2017-05-24 10:05:25 UTC, :next_state=>"free", :hardware_type=>"ethernet"}>]
E, [2017-05-24T12:06:08.245448 ] ERROR -- : Record 192.168.122.0/192.168.122.6 already exists
D, [2017-05-24T12:06:08.245471 ] DEBUG -- : Record 192.168.122.0/192.168.122.6 already exists (Proxy::DHCP::Collision)

When I switch smart-proxy back to 1.14 branch, it works just fine, here is how it created reservation (or dynamic lease if you prefer this term): https://gist.github.com/lzap/1beff14ed233d383a68380413db04f89


Related issues 2 (0 open2 closed)

Related to Foreman - Bug #19634: DHCP lease removal leads to errorClosedLukas Zapletal05/23/2017Actions
Related to Smart Proxy - Bug #18070: When adding a new dhcp reservation, ip and mac addresses should be checked not only against existing reservations but leases as wellClosed01/13/2017Actions
Actions #1

Updated by Lukas Zapletal over 7 years ago

  • Related to Bug #19634: DHCP lease removal leads to error added
Actions #2

Updated by Dominic Cleal over 7 years ago

  • Related to Bug #18070: When adding a new dhcp reservation, ip and mac addresses should be checked not only against existing reservations but leases as well added
Actions #3

Updated by The Foreman Bot over 7 years ago

  • Status changed from New to Ready For Testing
  • Assignee set to Anonymous
  • Pull request https://github.com/theforeman/smart-proxy/pull/531 added
Actions #4

Updated by Lukas Zapletal over 7 years ago

  • Translation missing: en.field_release set to 248

Scheduling this to 1.15 minor release, this is a blocker bug for discovery, thanks.

Actions #5

Updated by Anonymous over 7 years ago

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

Also available in: Atom PDF