Project

General

Profile

Bug #23166

Updated by Romke van Dijk almost 6 years ago

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: 

 <pre> ``` 
 $ 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  
 </pre> ``` 

 And if we request it with lower case: 

 <pre> ``` 
 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"} 
 </pre> ``` 

 But what happens when you sent a delete for this record that 'does not exist'? 
 <pre> ``` 
 $ 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 
 </pre> ``` 

 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? 

Back