Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1107706

Summary: DHCP lease reading is done in the wrong order
Product: Red Hat Satellite Reporter: Bryan Kearney <bkearney>
Component: Foreman ProxyAssignee: Katello Bug Bin <katello-bugs>
Status: CLOSED CURRENTRELEASE QA Contact: Kedar Bidarkar <kbidarka>
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.0.3CC: bbuckingham, bkearney, cperry, dcleal, dmitri, jmontleo, kbidarka, omaciel, stbenjam
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
URL: http://projects.theforeman.org/issues/5648
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-09-11 12:26:16 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Bryan Kearney 2014-06-10 12:54:41 UTC
DHCP uses a last-lease-wins system - new leases are appended to the leases file and automatically are preferred over earlier entries. However, the proxy uses a first-lease-wins, where we discard any leases that we already have in memory when parsing the leases file.

When you have a lease file like this:

    lease 192.168.123.58 {
  starts 5 2014/05/09 14:38:13;
  ends 5 2014/05/09 14:48:13;
  cltt 5 2014/05/09 14:38:13;
  binding state active;
  next binding state free;
  rewind binding state free;
  hardware ethernet 52:54:00:22:17:2b;
  uid "\001RT\000\"\027+";
}
lease 192.168.123.59 {
  starts 5 2014/05/09 14:39:00;
  ends 5 2014/05/09 14:49:00;
  cltt 5 2014/05/09 14:39:00;
  binding state active;
  next binding state free;
  rewind binding state free;
  hardware ethernet 52:54:00:22:17:2b;
}
lease 192.168.123.59 {
  starts 5 2014/05/09 14:39:12;
  ends 5 2014/05/09 14:49:12;
  cltt 5 2014/05/09 14:39:12;
  binding state active;
  next binding state free;
  rewind binding state free;
  hardware ethernet 52:54:00:22:17:2b;
}

Then the proxy would report that /dhcp/192.168.123.0/52:54:00:22:17:2b has IP 192.168.123.58 - when in actual fact it has 192.168.123.59.

We need to rewire the proxy to replace leases in memory as it parses down the file.

Comment 1 Bryan Kearney 2014-06-10 12:54:48 UTC
Created from redmine issue http://projects.theforeman.org/issues/5648

Comment 2 Bryan Kearney 2014-06-10 13:04:44 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/5648 has been closed

Comment 5 Kedar Bidarkar 2014-08-26 10:06:54 UTC
Any suggestions how do we test this. Meaning to say how do we force the client to get a new IP address and populate the leases file.

some suggestions would help.

Comment 6 Kedar Bidarkar 2014-08-26 10:34:26 UTC
Ok, after some investigation, I tried the below method and it worked, please confirm the verification steps for this bug.

a) On the capsule moved to the /var/lib/dhcpd/dhcpd.leases file and updated the IP/fixed-address for my host

b) restarted the dhcpd service on the capsule 

c) moved to the Host/vm restarted the network 

d) and checked whether the entry got updated under "/var/lib/dhclient/dhclient-eth0.leases" and the new ip address is shown when ifconfig is issued.

Comment 7 Kedar Bidarkar 2014-08-26 17:05:01 UTC
@dcleal: Can you please confirm whether the above procedure to verify is the right way, else please provide the verification steps.

Comment 8 Dominic Cleal 2014-08-27 07:37:23 UTC
I don't think those verification steps even use, let alone test the smart proxy.

I guess you could stop dhcpd, paste the three leases shown in comment #0 into dhcpd.leases file and then query the smart proxy with:

curl -k https://0.0.0.0:9000/dhcp/192.168.123.0/52:54:00:22:17:2b

And verify the IP address shown is 192.168.123.59, not .58.

Comment 10 Kedar Bidarkar 2014-08-27 14:12:19 UTC
@dcleal: can you please take a look, not sure if I am missing something.

My subnet, macaddress, being different, thought I will simply reuse the existing entries as per the dhclient-eth0.leases file and just update the rebind and expire entries for the second entry.

Comment 12 Dmitri Dolguikh 2014-09-01 11:31:01 UTC
Developer confirmed. Tested on cloud-qe-10.idmqe.lab.eng.bos.redhat.com

Comment 13 Kedar Bidarkar 2014-09-03 15:47:07 UTC
Tested with sat6-GA-snap7

lease 192.168.100.23 {
  starts 3 2014/09/03 15:16:57;
  ends 3 2014/09/03 15:26:57;
  cltt 3 2014/09/03 15:16:57;
  binding state active;
  next binding state free;
  hardware ethernet 52:54:00:29:04:a7;
}
lease 192.168.100.23 {
  starts 3 2014/09/03 15:21:43;
  ends 3 2014/09/03 15:31:43;
  cltt 3 2014/09/03 15:21:43;
  binding state active;
  next binding state free;
  hardware ethernet 52:54:00:29:04:a7;
}
lease 192.168.100.200 {
  starts 3 2014/09/03 15:32:11;
  ends 3 2014/09/03 15:36:11;
  cltt 3 2014/09/03 15:26:11;
  binding state active;
  next binding state free;
  hardware ethernet 52:54:00:29:04:a7;
}

[root@xxxx ~]# curl -k https://localhost:9090/dhcp/192.168.100.0/52:54:00:29:04:a7
{"ip":"192.168.100.200","starts":"Wed Sep 03 15:32:11 UTC 2014","state":"active","ends":"Wed Sep 03 15:36:11 UTC 2014","mac":"52:54:00:29:04:a7","subnet":"192.168.100.0/255.255.255.0"}


Installed Packages

    candlepin-0.9.23-1.el6_5.noarch
    candlepin-common-1.0.1-1.el6_5.noarch
    candlepin-scl-1-5.el6_4.noarch
    candlepin-scl-quartz-2.1.5-5.el6_4.noarch
    candlepin-scl-rhino-1.7R3-1.el6_4.noarch
    candlepin-scl-runtime-1-5.el6_4.noarch
    candlepin-selinux-0.9.23-1.el6_5.noarch
    candlepin-tomcat6-0.9.23-1.el6_5.noarch
    createrepo-0.9.9-21.2.pulp.el6sat.noarch
    elasticsearch-0.90.10-6.el6sat.noarch
    katello-1.5.0-30.el6sat.noarch
    katello-certs-tools-1.5.6-1.el6sat.noarch
    katello-default-ca-1.0-1.noarch
    katello-installer-0.0.64-1.el6sat.noarch
    katello-server-ca-1.0-1.noarch
    mod_wsgi-3.4-1.pulp.el6sat.x86_64
    pulp-katello-0.3-4.el6sat.noarch
    pulp-nodes-common-2.4.1-0.5.rc1.el6sat.noarch
    pulp-nodes-parent-2.4.1-0.5.rc1.el6sat.noarch
    pulp-puppet-plugins-2.4.1-0.5.rc1.el6sat.noarch
    pulp-puppet-tools-2.4.1-0.5.rc1.el6sat.noarch
    pulp-rpm-plugins-2.4.1-0.6.beta.el6sat.noarch
    pulp-selinux-2.4.1-0.5.rc1.el6sat.noarch
    pulp-server-2.4.1-0.5.rc1.el6sat.noarch
    python-gofer-qpid-1.3.0-1.el6sat.noarch
    python-isodate-0.5.0-1.pulp.el6sat.noarch
    python-kombu-3.0.15-12.pulp.el6sat.noarch
    python-pulp-bindings-2.4.1-0.5.rc1.el6sat.noarch
    python-pulp-common-2.4.1-0.5.rc1.el6sat.noarch
    python-pulp-puppet-common-2.4.1-0.5.rc1.el6sat.noarch
    python-pulp-rpm-common-2.4.1-0.6.beta.el6sat.noarch
    python-qpid-0.22-14.el6sat.noarch
    python-qpid-qmf-0.22-37.el6.x86_64
    qpid-cpp-client-0.22-42.el6.x86_64
    qpid-cpp-server-0.22-42.el6.x86_64
    qpid-cpp-server-linearstore-0.22-42.el6.x86_64
    qpid-java-client-0.22-6.el6.noarch
    qpid-java-common-0.22-6.el6.noarch
    qpid-proton-c-0.7-1.el6.x86_64
    qpid-qmf-0.22-37.el6.x86_64
    qpid-tools-0.22-12.el6.noarch
    ruby193-rubygem-katello-1.5.0-86.el6sat.noarch
    rubygem-hammer_cli_katello-0.0.4-14.el6sat.noarch
    rubygem-smart_proxy_pulp-1.0.1-1.1.el6sat.noarch

Comment 14 Bryan Kearney 2014-09-11 12:26:16 UTC
This was delivered with Satellite 6.0 which was released on 10 September 2014.