-
Notifications
You must be signed in to change notification settings - Fork 26
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
fix: use provision watcher logic for discovered devices #42
fix: use provision watcher logic for discovered devices #42
Conversation
edgexfoundry#39 Signed-off-by: Anthony Casagrande <anthony.j.casagrande@intel.com>
Codecov Report
@@ Coverage Diff @@
## main #42 +/- ##
==========================================
+ Coverage 40.77% 41.05% +0.27%
==========================================
Files 21 21
Lines 9094 9081 -13
==========================================
+ Hits 3708 3728 +20
+ Misses 4211 4181 -30
+ Partials 1175 1172 -3
Continue to review full report at Codecov.
|
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.
LGTM, but will let @tonyespy & @siggiskulason have final say
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.
Overall, the changes look good to me, however I do want to raise a few points that came up during this review.
This PR addresses issue #39, which in turn lists four issues in the device-sdk-go which were fixed:
- Bug in Provision Watcher whitelist logic device-sdk-go#598
- More Provision Watcher Bugs device-sdk-go#606
- Bug in Provision Watcher whitelist logic device-sdk-go#598
- Discover function lock release issue device-sdk-go#609
I just wanted to note that 598 is listed twice, and double check whether there's actually a fourth issue, or whether the list should've only had three issues?
I'll also point out that none of the issue descriptions for the device-sdk-go issues include version numbers, so I had to do a bit of detective work to figure out which version the SDK actually had these bugs.
Finally, the locking issue (edgexfoundry/device-sdk-go#609) is a bit puzzling. I believe the original design was correct and that releasing the lock when the SDK read a list of devices from the channel, was intentional. Discovery() was never meant to be a long-running operation that trickled up devices over a long period of time, it was intended to be called and result in a batch of discovered devices to be returned. That said, it clearly wasn't well-documented in the device-sdk-go's godoc for the ProtocolDiscovery.Discover()
method:
// Discover triggers protocol specific device discovery, asynchronously
// writes the results to the channel which is passed to the implementation
// via ProtocolDriver.Initialize(). The results may be added to the device service
// based on a set of acceptance criteria (i.e. Provision Watchers).
One could argue that details about locking/synchronization in shouldn't be exposed in a public API, however there's no guidance to developers as to the fact that only a single instance of discovery can be running at a given time and that the Discover()
method must write data to the channel in order signal completion of the operation. If this had been clearly communicated, there would've been no reason to re-factor the SDK to use a wrapper function to release the lock on completion of the Discovery() method. The original implementation was much cleaner/correct Go IMHOP.
And finally, I'll mention that when the SDK was re-factored to "fix" this issue, the godoc still wasn't updated. I think it would be a good idea for us to do so... @iain-anderson @cloudxxx8
@tonyespy A few comments:
|
@tonyespy I can't comment on the re-factored version as I did not code-review it, but I can attest that the original code was not very pragmatic Go IMHO. As a developer I ran into many issues implementing the Discovery method due to the SDK (not just related to the locking), at which point I looked to the source to see why my code was not working as expected. From an outsider looking in, I was confused by the implementation as it did not seem to make sense.
|
Closes #39
Signed-off-by: Anthony Casagrande anthony.j.casagrande@intel.com
PR Checklist
Please check if your PR fulfills the following requirements:
What is the current behavior?
A workaround for adding devices directly to core-metadata due to legacy bugs in EdgeX's
device-sdk-go
.Issue Number:
#39
What is the new behavior?
Use the updated provision watcher code provided in EdgeX Hanoi.
Does this PR introduce a breaking change?
New Imports