Project

General

Profile

Bug #23166

Case sensitive and MAC addresses

Added by Romke van Dijk over 1 year ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Category:
DHCP
Target version:
-
Difficulty:
Triaged:
No
Bugzilla link:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

Hi there,

Been running into a bug with Hyper-V, dhcp-isc and Foreman 1.16. (All running latest version on Debian 9 or Windows Server 2016). Creating a host from the Foreman interface works just as intended, the VM is created and the boots correctly and I am able to start the Debian preseed for the host. However, during the final step of the unattended installation, a finish script will run: calling the foreman api and telling it that the build has finished. During this step, foreman finishes the machine. One of the step that it does is delete the DCHP lease and recreate it removing the requirement for provising. This is where the bug occurs.

Hyper-V output the MAC in uppercase, while ISC-DHCP records the in lowercase. The Foreman Proxy API seems to be case sensitive when it comes to MAC addresses. So whenever you request Foreman for the lowcase MAC address, the tell you that the mac address does not exist:

$ curl -k https://foreman.example.com:8443/dhcp/192.168.0.0/mac/00:15:5D:11:73:0F --cert /etc/puppetlabs/puppet/ssl/certs/foreman.example.com.pem --key /etc/puppetlabs/puppet/ssl/private_keys/foreman.example.com.pem
$ No DHCP record for MAC 192.168.0.0/00:15:5D:11:73:0F 

And if we request it with lower case:

curl -k https://foreman.example.com:8443/dhcp/192.168.0.0/mac/00:15:5d:11:73:0f --cert /etc/puppetlabs/puppet/ssl/certs/foreman.example.com.pem --key /etc/puppetlabs/puppet/ssl/private_keys/foreman.example.com.pem
{"name":"boyd-chafin.example.com","ip":"192.168.0.54","mac":"00:15:5d:11:73:0f","subnet":"192.168.0.0/255.255.255.0","type":"reservation","hostname":"boyd-chafin.example.com","deleteable":true,"hardware_type":"ethernet","filename":"pxelinux.0","nextServer":"192.168.0.1"}

But what happens when you sent a delete for this record that 'does not exist'?

$ curl -k -XDELETE https://foreman.example.com:8443/dhcp/192.168.0.0/mac/00:15:5D:11:73:0F --cert /etc/puppetlabs/puppet/ssl/certs/foreman.example.com.pem --key /etc/puppetlabs/puppet/ssl/private_keys/foreman.example.com.pem
$ echo $?
$ 0

Looking at the log file of the foreman proxy, you will see just a simple http 200 response for this call, but no communication has be done to the DHCP server. This is because Foreman 'thinks' that the record isn't there and thus not delete it. The next call after that is recreating the DHCP lease, but this time ISC-DHCP will tell you: 'no gonna happen, this lease already exist'. Resulting in the API returning an error and making the provision fail.

You can argue that the problem is with hyper-v, but mac addresses are not case sensitive and the foreman proxy API should not be case sensitive (for MAC addresses). How do you think about this?


Related issues

Related to Smart Proxy - Refactor #23187: Mac addresses passed to/returned from dhcp providers should be normalizedNew2018-04-09

Associated revisions

Revision 8a4bd9c1 (diff)
Added by Lukas Zapletal over 1 year ago

Fixes #23166 - MAC DHCP CRUD not case sensitive

History

#1 Updated by Romke van Dijk over 1 year ago

  • Description updated (diff)

#2 Updated by Lukas Zapletal over 1 year ago

  • Category set to DHCP

Hello there, nice analysis. Valid bug, perhaps the best solution is change on proxy side to default case which is being returned by ISC DHCP which is our "defacto standard" DHCP plugin.

#3 Updated by The Foreman Bot over 1 year ago

  • Assignee set to Lukas Zapletal
  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/smart-proxy/pull/575 added

#4 Updated by Anonymous over 1 year ago

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

#5 Updated by Dmitri Dolguikh over 1 year ago

  • Related to Refactor #23187: Mac addresses passed to/returned from dhcp providers should be normalized added

Also available in: Atom PDF