-
Notifications
You must be signed in to change notification settings - Fork 220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #2687 - Leases file is no longer being parsed on every request #409
Conversation
I see some huge refactoring in this PR, is this expected? |
@witlessbird : I'd be happy to test this. What changes/commits do I need to apply agains 1.11.1? |
@timogoebel: thanks a bunch! The easiest would be to use this branch -- all commits were made against develop (not 1.11), and the changes in the last commit depend on the changes in the first. |
There were the following issues with the commit message:
If you don't have a ticket number, please create an issue in Redmine, selecting the appropriate project. More guidelines are available in Coding Standards or on the Foreman wiki. This message was auto-generated by Foreman's prprocessor |
There were the following issues with the commit message:
If you don't have a ticket number, please create an issue in Redmine, selecting the appropriate project. More guidelines are available in Coding Standards or on the Foreman wiki. This message was auto-generated by Foreman's prprocessor |
@witlessbird : I tested this, but somehow it does not work 100%. With your patch:
Without your patch, it finds the entry:
In addition foreman_dhcp_brower Plugin shows the subnet being empty with your patch (it's not without). |
@timogoebel: thanks for testing this! To confirm: you are using isc dhcp (these changes are not relevant for other providers. Other providers can be broken in this branch atm). If so, you should see a list of lease and host records that were processed on startup, does it include the ones you search for? |
There were the following issues with the commit message:
If you don't have a ticket number, please create an issue in Redmine, selecting the appropriate project. More guidelines are available in Coding Standards or on the Foreman wiki. This message was auto-generated by Foreman's prprocessor |
@timogoebel: also, check there are no errors on startup related to dhcp... |
@witlessbird
|
@timogoebel: you should see something similar to:
Note a bunch of host- and lease-records being added (and deleted). Do you see anything like this? If not, can you check that dhcp_isc configuration is pointing to the correct (as in actually used by isc dhcpd) leases file? |
@timogoebel: additionally, you should periodically (depends on how busy your dhcpd is) see something similar to:
|
There were the following issues with the commit message:
If you don't have a ticket number, please create an issue in Redmine, selecting the appropriate project. More guidelines are available in Coding Standards or on the Foreman wiki. This message was auto-generated by Foreman's prprocessor |
Fixed a bunch (not all) of tests. @timogoebel: I may have fixed the issue you were seeing. Out of curiosity -- are you running smart-proxy under ruby 1.8.7? |
@witlessbird : Thanks. If I find the time today, I'll retest the latest version and let you know how it works. I'm using default ruby on rhel 7.2. $ ruby --version
ruby 2.0.0p598 (2014-11-13) [x86_64-linux] |
I plan to review it soon if it hasn't been done by then, not forgotten about it. |
[test] |
test failure has been fixed in #442. |
rebased, should fix test failures. |
@@ -102,15 +101,10 @@ def load_subnet_data | |||
load_subnet | |||
load_subnet_data | |||
|
|||
content_type :json | |||
record = server.find_record(@subnet.network, params[:record]) | |||
log_halt 404, "Record #{params[:network]}/#{params[:record]} not found" unless record | |||
server.del_record @subnet, record |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm unsure if this is correct with the native_ms provider - it looks like del_record
will return the string response from the execute
call to delete the record. Both the libvirt and ISC providers look like they're going to return nil
, but the execute response won't be valid JSON if that's what's returned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, responses to DELETE shouldn't have body anyway.
Thanks, it generally looks very good. My only main concern is that the new Proxy::DHCP::ISC::IscStateChangesObserver class doesn't appear to have any test coverage, but it could do with some. I think we can live without coverage of the platform-specific observers, unless you'd like to mock those too (which is probably quite straight forward), but this contains a mix of logic for parsing includes out of files, plus adding, removing and updating records in the subnet service which is important to have coverage of. |
Responded to feedback:
I promise I'll think about how to best test those -- it's a bit tricky as they essentially create an event loop. Can we continue without these tests for the time being please? |
Indeed, that's fine. Thanks for the update, the testing is much improved. Subject to #444 fixing tests first, this is reviewed. |
[test] with json_pure fixed. |
end | ||
|
||
def close | ||
fd.close unless fd.nil? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think @fd
also has to be set to nil here, otherwise the old fd is used when hosts_and_leases
is called again from leases_recreated
:
E, [2016-07-29T10:53:27.693723 #5691] ERROR -- : Error occured when monitoring /tmp/dhcp.leases D, [2016-07-29T10:53:27.693750 #5691] DEBUG -- : closed stream (IOError) /home/dcleal/code/foreman/smart-proxy/modules/dhcp_isc/leases_file.rb:13:in `read' /home/dcleal/code/foreman/smart-proxy/modules/dhcp_isc/leases_file.rb:13:in `hosts_and_leases' /home/dcleal/code/foreman/smart-proxy/modules/dhcp_isc/isc_state_changes_observer.rb:35:in `block in leases_recreated' /home/dcleal/code/foreman/smart-proxy/modules/dhcp_common/subnet_service.rb:140:in `block in group_changes' /home/dcleal/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize' /home/dcleal/code/foreman/smart-proxy/modules/dhcp_common/subnet_service.rb:140:in `group_changes' /home/dcleal/code/foreman/smart-proxy/modules/dhcp_isc/isc_state_changes_observer.rb:27:in `leases_recreated' /home/dcleal/code/foreman/smart-proxy/modules/dhcp_isc/inotify_leases_file_observer.rb:25:in `block (2 levels) in monitor_leases' /home/dcleal/code/foreman/smart-proxy/modules/dhcp_isc/inotify_leases_file_observer.rb:17:in `each' /home/dcleal/code/foreman/smart-proxy/modules/dhcp_isc/inotify_leases_file_observer.rb:17:in `block in monitor_leases'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duh!
Also: refs 12392, #12359, #12425, #1090
|
Merged as 7bd71b5, thanks @witlessbird. |
This is work in progress and currently only isc dhcpd running on linux is supported (support for BSD is coming). Please ignore the failing tests, these are due to changes in internal API.