When debugging a pdns-recursor issue, I noticed that vyos-hostsd was frequently reloading it every time the DHCP lease renews on the WAN interface.
From the logs on hostsd we can see it is responding to a set of nameservers and search domains being removed and then replaced with identical ones. It then re-renders multiple files and calls pdns-recursor to reload its config.
I do not have the router configured to use the nameservers/search domains from DHCP, so none of this actually ends up being rendered into any files. The rendered files before and after the apply operation are the same, as is the vyos-hostsd state file.
Jul 29 05:28:49 vyos-hostsd[1111]: Request data: {"type": "search_domains", "op": "delete", "data": ["dhcp-eth0"]} Jul 29 05:28:49 vyos-hostsd[1111]: Saving state to /run/vyos-hostsd/vyos-hostsd.state Jul 29 05:28:49 vyos-hostsd[1111]: Sent response: {'data': None} Jul 29 05:28:49 vyos-hostsd[1111]: Request data: {"type": "search_domains", "op": "add", "data": {"dhcp-eth0": ["attlocal.net"]}} Jul 29 05:28:49 vyos-hostsd[1111]: Saving state to /run/vyos-hostsd/vyos-hostsd.state Jul 29 05:28:49 vyos-hostsd[1111]: Sent response: {'data': None} Jul 29 05:28:49 vyos-hostsd[1111]: Request data: {"type": "name_servers", "op": "delete", "data": ["dhcp-eth0"]} Jul 29 05:28:49 vyos-hostsd[1111]: Saving state to /run/vyos-hostsd/vyos-hostsd.state Jul 29 05:28:49 vyos-hostsd[1111]: Sent response: {'data': None} Jul 29 05:28:49 vyos-hostsd[1111]: Request data: {"type": "name_servers", "op": "add", "data": {"dhcp-eth0": ["192.168.1.254"]}} Jul 29 05:28:49 vyos-hostsd[1111]: Saving state to /run/vyos-hostsd/vyos-hostsd.state Jul 29 05:28:49 vyos-hostsd[1111]: Sent response: {'data': None} Jul 29 05:28:49 vyos-hostsd[1111]: Request data: {"op": "apply"} Jul 29 05:28:49 vyos-hostsd[1111]: Applying 4 changes Jul 29 05:28:49 vyos-hostsd[1111]: Writing /etc/resolv.conf Jul 29 05:28:49 vyos-hostsd[1111]: Writing /etc/hosts Jul 29 05:28:49 vyos-hostsd[1111]: Writing /run/powerdns/recursor.vyos-hostsd.conf.lua Jul 29 05:28:49 vyos-hostsd[1111]: Writing /run/powerdns/recursor.forward-zones.conf Jul 29 05:28:50 vyos-hostsd[1111]: Running "rec_control reload-lua-config" Jul 29 05:28:50 vyos-hostsd[1111]: Running "rec_control reload-zones" Jul 29 05:28:50 vyos-hostsd[1111]: Success Jul 29 05:28:50 vyos-hostsd[1111]: Saving state to /run/vyos-hostsd/vyos-hostsd.state Jul 29 05:28:50 vyos-hostsd[1111]: Sent response: {'data': {'message': 'Applied 4 changes'}}
The impact of this whole operation is just some CPU usage and log spam, both from hostsd and recursor. Ideally we should track when the before/after state is identical and skip re-render/reload in those cases.