home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
69.03k stars 28.27k forks source link

Add support for round-robin DNS #115218

Closed pemontto closed 1 week ago

pemontto commented 1 month ago

Breaking change

This PR tries to avoid breaking changes by keeping the default behaviour and only exposing the round-robin IPs in the attributes.

Proposed change

Similar to #91927

If a hostname returns multiple A-records (as is the case with AWS-loadblancers and other autoscaling services) the current implementation will act like as normal dns-resolver and pick and return a random A-record. The sensor will then just flip-flop between the available records which probably isn't what you want. This change will return a comma-seperated sorted list of all a-records if there is more than one. In the case of a single A-record it will behave as normal

This PR supports hostnames that return multiple round-robin A records and sorts the IPs (both v4 and v6) naturally.

image image

Type of change

Additional information

Checklist

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

To help with the load of incoming pull requests:

home-assistant[bot] commented 1 month ago

Hey there @gjohansson-st, mind taking a look at this pull request as it has been labeled with an integration (dnsip) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `dnsip` can trigger bot actions by commenting: - `@home-assistant close` Closes the pull request. - `@home-assistant rename Awesome new title` Renames the pull request. - `@home-assistant reopen` Reopen the pull request. - `@home-assistant unassign dnsip` Removes the current integration label and assignees on the pull request, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.
home-assistant[bot] commented 1 month ago

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks :+1:

Learn more about our pull request process.

gjohansson-ST commented 1 month ago

@pemontto could we add a documentation PR to this? I think it would be nice to have this behavior and attributes described in the documentation. Thanks 👍

I think this PR looks go and ready to merge 👍

pemontto commented 1 month ago

@gjohansson-ST I've added some wording to the documentation on the 2nd dot point where a hostname is specified.

gjohansson-ST commented 1 week ago
---------- coverage: platform linux, python 3.12.3-final-0 -----------
Name                                            Stmts   Miss  Cover   Missing
-----------------------------------------------------------------------------
homeassistant/components/dnsip/__init__.py         12      0   100%
homeassistant/components/dnsip/config_flow.py      65      0   100%
homeassistant/components/dnsip/const.py            14      0   100%
homeassistant/components/dnsip/sensor.py           61      0   100%
-----------------------------------------------------------------------------
TOTAL                                             152      0   100%