-
Notifications
You must be signed in to change notification settings - Fork 0
Refactor libvirt event handling + reconcile when domains change #41
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
6a647bd to
7d886e3
Compare
61d380a to
04e1c00
Compare
mchristianl
left a comment
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've marked
- a data race on shared libvirt connection
- race condition on event handler map
- reconnect is logged but not (yet) implemented?
- busy loop in runEventLoop
- maybe unbuffered channels are not intended here
Again, I think that concurrency and shared access are a bit spread over different locations in the source code. Therefore I would suggest to test this in a simpler setting first but let's discuss this.
Also, as we've already discussed I don't trust the libvirt socket and
- currently we won't get lifecycle events on migration (the qemu driver has implemented them) so pure event-based state tracking is blocked by this feature
- at least restarting the libvirt socket should be supported (but I may be mistaken to just have overlooked the logic if present)
2a49401 to
e649f93
Compare
|
^ Added a goroutine which triggers a reconcile every minute. |
Merging this branch changes the coverage (1 decrease, 2 increase)
Coverage by fileChanged files (no unit tests)
Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code. Changed unit test files
|
With this change, we now reconcile the hypervisor resource if any libvirt domain lifecycle events occur. This keeps the hypervisor allocation up to date and simplifies how we manage the domain list.
We can only subscribe to libvirt events once. This means, we have to pull out the subscription logic from the
runMigrationListenerfunction inlibvirt_events.go. We provide a newWatchDomainChangesinterface function which can be used to subscribe to libvirt events, and reuse it for the existing migration watching and lifecycle logging. Furthermore, the distribution of libvirt events to the listeners is handled by a new event loop. Then, we also separate the logic unrelated to "migration watching" out, improving the overall structure and clarity of the code.Finally, we make the hypervisor controller reconcile as soon as we obtain a new domain lifecycle event. This is done with the proper mechanism provided by the controller-runtime client library: raw channel sources. The libvirt event subscription is wired together with the controller-runtime event channel on startup of the manager.