DHCP reservations do not show up in Foreman DHCP-plugin GUI when creating a host


When create a host via Foreman the reservation does not show up in the DHCP-plugin in the foreman GUI.

Expected outcome:
When creating a new host I expect to see the reservation Foreman did to show up in the DHCP reservation list of the DHCP-plugin.

Foreman and Proxy versions:
Foreman 1.19.0-1
Foremanproxy 1.19.0-1

Foreman and Proxy plugin versions:

Other relevant data:
[e.g. logs from Foreman and/or the Proxy, modified templates, commands issued, etc]
(for logs, surround with three back-ticks to get proper formatting, e.g.)
Foreman-proxy logs when I browse to a list of reservations for a subnet.

I, [2018-10-30T13:11:07.810737 4a3caebf]  INFO -- : ::ffff: - - [30/Oct/2018:13:11:07 +0100] "GET /dhcp/ HTTP/1.1" 200 7074 0.0122

I, [2018-10-30T13:11:07.971399 4a3caebf]  INFO -- : ::ffff: - - [30/Oct/2018:13:11:07 +0100] "GET /dhcp/ HTTP/1.1" 200 7074 0.0014

Is this as intended or am I missing something?

Hey, can you hit the smart-proxy endpoint with curl? What to you see?

What DHCP provider do you use? ISC? Is this locally running ISC DHCP via inotify?

Hi Izap,

Curl request gives me no reservations either:

{"reservations":[],"leases":[{"name":"lease-0013d3f37604","ip":"10.25... enz

In the leases part I see the leases that exist in my dhcpd.leases file.

Just installed a server and I can see the fixed-address in the leases file, but the proxy does not return that reservation. There is one network I have with already existing reservations. The proxy does return those. But when I create a new host in that network it does not show that reservation either.

I use ISC locally btw. :slight_smile:

my guess is that you don’t actually have a reservation for that host, just
leases. was it created by foreman? (with dhcp enabled for that subnet?)
assuming its enabled, you can try selecting the checkbox next to the host
and from the dropdown chose rebuild configs, if configured correctly
(proxy + dhcp + subnet assign to that proxy) will create the reservation if
it didnt exists to begin with.

Hi, thanks for you reply.

I again created a host in a network with pre-existing reservations. I have DHCP enabled for that subnet. IP assignment worked and it got Host got deployed and is working.

Next I asked the proxy to give me the reservations:

{"reservations":[{"name":"linipa01.example.com","ip":"","mac":"52:54:00:97:02:50","subnet":"","type":"reservation","deleteable":true,"hostname":"linipa01.example.com","hardware_type":"ethernet","filename":"pxelinux.0","nextServer":""},{"name":"linkvm01.example.com","ip":"","mac":"d0:67:e5:e7:07:d6","subnet":"","type":"reservation","deleteable":true,"hostname":"linkvm01.example.com","hardware_type":"ethernet","filename":"","nextServer":""},{"name":"linlog02.example.com","ip":"","mac":"52:54:00:8e:f1:10","subnet":"","type":"reservation","deleteable":true,"hostname":"linlog02.example.com","hardware_type":"ethernet","filename":"pxelinux.0","nextServer":""},{"name":"linkvm02.example.com","ip":"","mac":"d0:50:99:c0:61:fd","subnet":"","type":"reservation","deleteable":true,"hostname":"linkvm02.example.com","hardware_type":"ethernet","filename":"pxelinux.0","nextServer":""},{"name":"linmon01.example.com","ip":"","mac":"52:54:00:ba:fe:ac","subnet":"","type":"reservation","deleteable":true,"hostname":"linmon01.example.com","hardware_type":"ethernet","filename":"pxelinux.0","nextServer":""},{"name":"linkvm03.example.com","ip":"","mac":"d4:ae:52:ca:a0:e2","subnet":"","type":"reservation","deleteable":true,"hostname":"linkvm03.example.com","hardware_type":"ethernet","filename":"","nextServer":""},{"name":"lingtw01.example.com","ip":"","mac":"52:54:00:98:2a:41","subnet":"","type":"reservation","deleteable":true,"hostname":"lingtw01.example.com","hardware_type":"ethernet","filename":"pxelinux.0","nextServer":""},{"name":"lindat01.example.com","ip":"","mac":"52:54:00:b8:11:fb","subnet":"","type":"reservation","deleteable":true,"hostname":"lindat01.example.com","hardware_type":"ethernet","filename":"pxelinux.0","nextServer":""},{"name":"linutl02.example.com","ip":"","mac":"52:54:00:a0:0b:77","subnet":"","type":"reservation","deleteable":true,"hostname":"linutl02.example.com","hardware_type":"ethernet","filename":"pxelinux.0","nextServer":""},{"name":"linutl04.example.com","ip":"","mac":"52:54:00:34:bd:0d","subnet":"","type":"reservation","deleteable":true,"hostname":"linutl04.example.com","hardware_type":"ethernet","filename":"pxelinux.0","nextServer":""}],"leases":[{"name":"lease-52540028aecc","ip":"","mac":"52:54:00:28:ae:cc","subnet":"","starts":"2018-10-29 12:26:19 UTC","ends":"2018-10-29 14:26:19 UTC","state":"active","type":"lease","tstp":"2018-10-29 15:26:19 UTC","tsfp":"2018-10-29 15:26:19 UTC","atsfp":"2018-10-29 15:26:19 UTC","cltt":"2018-10-29 12:26:19 UTC","next_state":"expired","hardware_type":"ethernet","client_hostn....bla bla lots of lease but also not the .93....mer\""}]}

(sorry for the layout) It gives me the pre-existing reservations but not the one for my dhcptest host with .93.

After that I tried to do a ‘rebuild config’ and it gives me a DHCP error. The output of the proxy is:

I, [2018-10-31T09:34:21.182179 ]  INFO -- : ::1 - - [31/Oct/2018:09:34:21 +0100] "GET /dhcp/ HTTP/1.1" 200 7074 0.0015

I, [2018-10-31T09:37:16.549336 d72907df]  INFO -- : ::ffff: - - [31/Oct/2018:09:37:16 +0100] "GET /tftp/serverName HTTP/1.1" 200 17 0.0006

I, [2018-10-31T09:37:16.691985 d72907df]  INFO -- : ::ffff: - - [31/Oct/2018:09:37:16 +0100] "DELETE /dhcp/ HTTP/1.1" 200 - 0.0008

E, [2018-10-31T09:37:16.768558 d72907df] ERROR -- : Omshell failed:
> > > > obj: <null>
, > obj: host
, > obj: host
, name = "dhcptest.example.com"
, > obj: host
, name = "dhcptest.example.com"
, ip-address = 0a:19:0a:5d
, > obj: host
, name = "dhcptest.example.com"
, ip-address = 0a:19:0a:5d
, hardware-address = 52:54:00:cc:52:e5
, > obj: host
, name = "dhcptest.example.com"
, ip-address = 0a:19:0a:5d
, hardware-address = 52:54:00:cc:52:e5
, hardware-type = 1
, > obj: host
, name = "dhcptest.example.com"
, ip-address = 0a:19:0a:5d
, hardware-address = 52:54:00:cc:52:e5
, hardware-type = 1
, statements = "filename = "pxelinux.0"; next-server = 0a:19:0a:0b; option host-name = "dhcptest.example.com";"
, > can't open object: already exists
, obj: host
, name = "dhcptest.example.com"
, ip-address = 0a:19:0a:5d
, hardware-address = 52:54:00:cc:52:e5
, hardware-type = 1
, statements = "filename = "pxelinux.0"; next-server = 0a:19:0a:0b; option host-name = "dhcptest.example.com";"
, >
E, [2018-10-31T09:37:16.769337 d72907df] ERROR -- : Failed to add DHCP reservation for dhcptest.example.com ( / 52:54:00:cc:52:e5): Entry already exists

And that is correct. My leases file has:

host dhcptest.example.com {
  hardware ethernet 52:54:00:cc:52:e5;
        supersede server.filename = "pxelinux.0";
        supersede server.next-server = 0a:19:0a:0b;
        supersede host-name = "dhcptest.example.com";

So it seems like I have a reservation but the proxy is still not showing it…?

Hmm looks like a ‘did you try turning it off an on again’ situation. I noticed manually adding a reservation wasn’t working anymore either. So I kicked the foreman-proxy and all my reservations appeared…? Caching…? Still weird though.

Creating a host or adding a reservation manually seems to work again now. Wonder if it will stay that way… :wink:

Proxy relies on inotify on linux to determine there was a configuration file change. This only works if your leases file is mounted locally, it won’t work if you have NFS for example.

You are on Linux, are you? Is this CentOS?

Yes, I am running CentOS and the leases file is mounted locally.

Weird, well it works now, feel free to mark your comment as solution as soon as you confirm.

Thanks for your help! I will mark this as solved (for now). :slight_smile: