-
Notifications
You must be signed in to change notification settings - Fork 121
refresh records when leases file is updated #139
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #139 +/- ##
==========================================
+ Coverage 41.85% 43.00% +1.14%
==========================================
Files 14 14
Lines 743 765 +22
==========================================
+ Hits 311 329 +18
- Misses 387 389 +2
- Partials 45 47 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
fc9d148
to
4f2e5b6
Compare
Alternatively, instead of using fsnotify and an asynchronous update of the database, it would also be possible to:
What do you think @Natolumin ? |
I don't have a strong opinion on that point, doing it async is ok I think, and doing it during requests may impact latency a bit but not noticeably (unless the file is on NFS or something) What I'm less sure about here is the design idea that it gets updated without any user intervention when the file updates. 2 (somewhat related) concerns:
I'm not saying we need to address all of these right now! it's probably fine to select a few points we cannot/don't want to handle and explicitly call them out in the documentation. Traditionally, unix programs have been using SIGHUP to reload this kind of configuration and/or files, and we could probably consider something like that, although that would be a larger project and probably not in the scope of this PR if we want to do it properly I think I'll need more time to make up my own mind about what I think we should be doing here, but please give it a thought and share your own conclusions as well |
Any chance of getting this merge? dhcplb by facebook also uses fsnotify to get reload files on changes. Code is here: https://github.com/facebookincubator/dhcplb/blob/2e66b270a1a257e37b07fdbc72b719914fe5ab5c/lib/filesourcer.go |
@Natolumin I understand the issues when a file is appended to instead of replaced, but replacing the entire file would be my exact use case and we could specify this in the docs. I've been thinking about extending the Plugin interface to include a Reload/Refresh function that is triggered on SIGHUP. This would specifically not reload the configuration/interfaces bound/loaded plugins of the server itself, but it could be very helpful in this case. If you would like to see a proposal for that as well/instead, I'm happy to send in another PR. This would fit my use case fine as well, so I'm fine with either solution. |
In #143 I showcase how I would like to implement refreshing plugins on SIGHUP. Note that it is far from done, first wanted to get your opinions. If we would go for such an approach, I think it is far more flexible and this PR would be obsolete. |
I got to the same conclusion, that this is mostly fine and will work for most usecases. |
Signed-off-by: Reinier Schoof <reinier@skoef.nl>
4f2e5b6
to
3492d42
Compare
I'm fine with that @Natolumin, thanks for considering this PR! |
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'll run a few tests against this later today, but code looks good and I'll merge it if nothing comes up in the test
sorry for the long wait, this looks all good :) |
Thanks @Natolumin ! |
The leases in my environment are fetched over HTTP from an API and are updated periodically. Since I don't want to restart CoreDHCP every time the leases change, this PR should make the file plugin automatically update the lease database when the file was changed. It does so in a best-effort: if it can't update the database it will show a warning but nothing will break.