Skip to content

Ensure ServiceInfo orders newest addresess first#1012

Merged
bdraco merged 4 commits into
python-zeroconf:masterfrom
bdraco:stale_a_records_1s
Oct 22, 2021
Merged

Ensure ServiceInfo orders newest addresess first#1012
bdraco merged 4 commits into
python-zeroconf:masterfrom
bdraco:stale_a_records_1s

Conversation

@bdraco
Copy link
Copy Markdown
Member

@bdraco bdraco commented Oct 22, 2021

  • In order to comply with rfc6762 section 10.2, cache flushed
    records expire 1s in the future. If a ServiceInfo request is
    made while the records are still in the cache and not yet expired,
    the first address would be returned which was the address that
    was about to be expunged from the cache. We now return the newest
    address first to reduce the risk consumers of ServiceInfo will
    try the old address.

    This effectively restores the behavior before 1s cache flush
    expire was added for callers that rely on this.

cc @chemelli74. This should fix the behavior you were seeing with shelly on ip change

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Oct 22, 2021

Codecov Report

Merging #1012 (17b12f3) into master (61275ef) will decrease coverage by 0.07%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1012      +/-   ##
==========================================
- Coverage   99.76%   99.68%   -0.08%     
==========================================
  Files          23       23              
  Lines        2504     2524      +20     
  Branches      409      412       +3     
==========================================
+ Hits         2498     2516      +18     
- Misses          3        5       +2     
  Partials        3        3              
Impacted Files Coverage Δ
zeroconf/_services/info.py 100.00% <100.00%> (ø)
zeroconf/_utils/asyncio.py 89.28% <0.00%> (-3.58%) ⬇️
zeroconf/_services/browser.py 100.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 61275ef...17b12f3. Read the comment docs.

- In order to comply with rfc6762 section 10.2, cache flushed
  records expire 1s in the future. If a ServiceInfo request is
  made while the records are still in the cache and not yet expired,
  the first address would be returned which was the address that
  was about to be expunged from the cache. We now return the newest
  address first to reduce the risk consumers of ServiceInfo will
  try the old address.

  This effectively restores the behavior before 1s cache flush
  expire was added for callers that rely on this.
@bdraco bdraco force-pushed the stale_a_records_1s branch from dca46fb to 17b12f3 Compare October 22, 2021 20:19
Copy link
Copy Markdown

@chemelli74 chemelli74 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx @bdraco , tested and working perfectly!

@bdraco
Copy link
Copy Markdown
Member Author

bdraco commented Oct 22, 2021

The project coverage is not actually decreased, we are not reporting python 3.6 coverage anymore, and will go away once we drop python 3.6 in #1009

@bdraco bdraco marked this pull request as ready for review October 22, 2021 22:41
@bdraco bdraco changed the title Ensure ServiceInfo orders newest addreses first Ensure ServiceInfo orders newest addresess first Oct 22, 2021
@bdraco bdraco merged commit 87a4d8f into python-zeroconf:master Oct 22, 2021
@bdraco bdraco deleted the stale_a_records_1s branch October 22, 2021 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants