Class Unique fix - #217
Conversation
|
@jstasiak, I’m not expecting you to be prepared to merge this yet, but wanted to have you look over where this is going and see if there is anyone you know of who could help review these changes as I appreciate you mat not be familiar with the spec as we discussed before. |
|
Cheers, I'll have a look at the patch (and at the specs to educate myself) some time this week. |
|
Having looked through the spec and the code, there are a number of areas that I have concerns about, what’s your view on how you’d like to work on these? Perhaps discuss via Slack? Also do you think that a number of your other contributors might like to collaborate on this? |
|
If no one else chimes in here we're on our own I'm afraid. I'd say discussing things here is all right. |
|
Ok, I’ll reopen this PR to debate this one and raise some issues on the main page to discuss each concern to see if anyone else chimes in |
|
I'd love to participate in discussion, but I don't remember what CLASS_UNIQUE exactly does and have no time right now to dive into RFCs.. Could you at least point to the exact paragraph where it's discussed @mattsaxon? |
|
The _CLASS_UNIQUE bit sets the cache-flush bit in the class field. Here is the portion of the spec that refers to it https://tools.ietf.org/html/rfc6762#section-10.2 Also see https://tools.ietf.org/html/rfc6762#section-2 on unique vs shared records. Effectively, the _CLASS_UNIQUE bit tells the client cache to flush, i.e. the responder is saying I own this record (set) so you should remove all other references to this record in your cache. @dtantsur for your use case, I believe the right way is to;
The complexities I can see with this are.
Can you outline the sort of records that you think you want to publish (PTR, SRV, TXT and A/AAAA) so I can get my head around how you think this should work (i.e. the second mode of operation). Note I suspect this might be documented, at least to some extent in https://tools.ietf.org/html/rfc6763, but haven't yet read it in any detail. |
|
I'm publishing A, AAAA, TXT and SRV. They're published completely the same from all responders, so UNIQUE will probably work, but I'm not exactly sure. |
|
Thanks for the feedback. Glad this shouldn’t conflict with your use case. Would you be able to rest this for me or do you need other changes.... Have you had a chance to review my proposal on #163? |
|
@jstasiak, this commit is actually a good one! This failure is worth you taking a look at, I've been having intermittent failure such as this pretty much as long as I can remember, do you ever see them? If you click restart build, I suspect it will pass. The failure only occurs sometimes and in a typical build set will only fail one build. Have you seen this before? |
|
Having looked through both RFC6762 and RFC6763 now quite a bit, I'm convinced the implementation is correct. Here are the section that justify this; For PTR records, they should be shared https://tools.ietf.org/html/rfc6762#section-8.3 For A and AAAA record, they should be unique https://tools.ietf.org/html/rfc6762#section-6 This implies that SRV records should also be unique Since SRV and TXT records come together, the TXT records should therefore also be unique. |
jstasiak
left a comment
There was a problem hiding this comment.
LGTM, I agree with your analysis.
@jstasiak, this commit is actually a good one! This failure is worth you taking a look at, I've been having intermittent failure such as this pretty much as long as I can remember, do you ever see them? If you click restart build, I suspect it will pass. The failure only occurs sometimes and in a typical build set will only fail one build. Have you seen this before?
I don't think I've seen this particular one before, but there is one or two tests that sometimes break on PyPy, I don't know why so far.
| or record.type == _TYPE_A | ||
| or record.type == _TYPE_AAAA | ||
| ): | ||
| assert record.unique |
There was a problem hiding this comment.
I'd think about putting those if/assert blocks in a function, but it's no biggie. I'd at least remove the comments, the code is crystal clear on what it's going on here.
There was a problem hiding this comment.
Happy to remove comment, do you want me to resubmit a PR?
There was a problem hiding this comment.
That's up to you, we can merge as-is.
There was a problem hiding this comment.
I went ahead and merged it, we can clean it up later.
| zc.unregister_service(info) | ||
|
|
||
|
|
||
| if __name__ == "__main__": |
There was a problem hiding this comment.
Let's keep this out – it'd suggest that using the unittest module is a supported way of running project's test, but it's not.
There was a problem hiding this comment.
Sorry about this creating in again, I’ve stopped using this method myself now anyway!
|
I restarted the build, once it passes this can be merged I think. |
Fixes issues with shared records being used where they shouldn't be.
PTR records should be shared, but SRV, TXT and A/AAAA records should be unique.
Whilst mDNS and DNS-SD in theory support shared records for these types of record, they are not implemented in python-zeroconf at the moment.
See zeroconf.check_service() method which verifies the service is unique on the network before registering.