Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix lease return logic. #17

Merged
merged 1 commit into from

2 participants

Cody Herriges Tommy Bishop
Cody Herriges
ody commented

Identified that the logic that the last lease in the file wins when
it is actually the last lease to expire. This requires we sort the
list of end times and select that last one.

Cody Herriges
ody commented

This request feels a bit like a 'ah duh' moment. When I previous identified that it was the last in the lease file it was a coincidence. Would be cool if someone else could test this real quick since I didn't can't this the first time around.

Tommy Bishop
Owner

@ody,

Can you post a gist of your leases file? I think I may be missing something as I can't seem to manually reproduce this.

Thanks.

Cody Herriges

https://gist.github.com/1846011

Macaddress 00:0c:29:1d:6f:c8 first appears at the top with an expiry of 2012/01/30 with an IP of 172.16.210.142, same macaddress again at the bottom expires 2012/02/08. Before my original change fission would have returned the old address and my VM would have gotten the later expiry one. In the specific gist my first change would have been sufficient but I have ran into a couple situations where the entries are reversed, the later expiry being at the top, which by happenstance would work the way the code originally was but obviously the way the code originally was puts me in the situation I am trying to avoid, fission saying my ip is actually one that has either expired or expires sooner than the ip I do have.

I think I maybe seeing this behavior because I use fusion/fission more like Vagrant/$cloudprovider so I am cloning and destroying vm sometimes several times a day.

Cody Herriges ody Fix lease return logic.
  Identified that the logic that the last lease in the file wins when
  it is actually the last lease to expire.  This requires we sort the
  list of end times and select that last one.
0a46bab
Tommy Bishop thbishop merged commit 98e2231 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 16, 2012
  1. Cody Herriges

    Fix lease return logic.

    ody authored
      Identified that the logic that the last lease in the file wins when
      it is actually the last lease to expire.  This requires we sort the
      list of end times and select that last one.
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  lib/fission/lease.rb
2  lib/fission/lease.rb
View
@@ -97,7 +97,7 @@ def self.find_by_mac_address(mac_address)
if all_response.successful?
response = Response.new :code => 0
- response.data = all_response.data.find_all { |l| l.mac_address == mac_address }.last
+ response.data = all_response.data.find_all { |l| l.mac_address == mac_address }.sort_by { |l| l.end }.last
else
response = all_response
end
Something went wrong with that request. Please try again.