tomaae / homeassistant-truenas

TrueNAS integration for Home Assistant
Apache License 2.0
194 stars 19 forks source link

[Feature] Limit how often the addon triggers a check for a new TrueNAS update #92

Closed heymoe closed 1 year ago

heymoe commented 1 year ago

Is your feature request related to a problem? Please describe.

I run Pi-Hole on my home network and noticed that my TrueNAS server was generating nearly 30,000 DNS requests per day (about 20 requests per min) all to update.freenas.org, update-master.ixsystems.com and update.ixsystems.com which put it well ahead any other device on my home network by the total number of DNS queries per day. I originally thought the issue was being caused by a recent TrueNAS update and / or TrueNAS enabling some sort of data / telemetry collection by mistake since I disabled all those features. After checking my TrueNAS setup I didn't find anything there that would be causing the issue but then I remembered I was collecting stats about my TrueNAS server in Home Assistant using this addon. So, I temporally disabled this addon and check my Pi-Hole stats 24 hours later and sure enough my TrueNAS server reported almost no DNS queries in Pi-Hole.

Describe the solution you'd like

It seems to be a little excessive to check and see if there is a new TrueNAS update ever minute. I don't need to know more or less in real time the exact moment a new update is available. I'm pretty sure TrueNAS itself doesn't do a new update check more than once a day if you have auto update check enabled.

So, as a feature solution I think limiting the addon from triggering the check for new update api call to once an hour would be more than sufficient OR make the new update check interval configurable so we can chose how often the addon triggers a new update check.

Describe alternatives you've considered

The ability to disable the addon from triggering the check for new updates api call on the TrueNAS server and just get the current update status from the TrueNAS server and letting the TrueNAS server do its normal update check on its schedule.

Additional context

None to note at the moment.

tomaae commented 1 year ago

yes, this should be moved to separate listener

tomaae commented 1 year ago

fixed in dev, timer is set to 12 hours for update query

JagerSprinkles commented 9 months ago

Where can we find the dev branch? I installed the version from the master branch and this is still an issue. Is there a different repo somewhere?

@tomaae

tomaae commented 9 months ago

Master branch is dev branch

JagerSprinkles commented 9 months ago

I just reinstalled from the master branch commit 1918a8d. It seems the issue still persists. There are still multiple DNS queries for update.ixsystems.com, update-master.ixsystems.com, and update.freenas.org every 15 seconds. Is there anything else I need to change to have this update check not occur as frequently?

Edit: After switching to master branch these DNS queries have increased 3-5 times more than they were previously. Multiple requests every 15 seconds, (Update check seems to be performed every 15 seconds)

Edit 2: The changes in master branch have definitely caused a 5x increase in DNS queries related to this. Reverting back to v1.2.5 brings it back down to about 5 requests a minute. (Update check seems to be performed every 60 seconds)

JagerSprinkles commented 9 months ago

@heymoe do you still have this issue? It does not seem resolved to me. The master branch makes four times as many update checks so there are four times as many DNS requests when I tested it.

Am I missing some setting related to this update check or something?

heymoe commented 9 months ago

Hey, sorry for the delay in replying.. I didn't get around to testing this last Sept when @tomaae put the fix in because I too didn't know that the master branch was the dev branch so I figured a new release of this addon would come out soon and I would just installed the new version with this fix then.

Fast forward 5 months and no new release to install and then I saw @JagerSprinkles chime in recently so here I am.

Any ways, I just downloaded the master branch, installed it, rebooted HA and looked at my pi-Hole logs and it looks like it is still seeing around 12 requests/min split across update-master.ixsystems.com and update.ixsystems.com. I then disabled this addon and the requests no longer happen every min. I then re-enabled this addon and sure enough back to 12 requests/min.

So indeed, whatever patch / fix that was put in place did not solve the problem I originally reported.

tomaae commented 9 months ago

yea, I see it never went through to github. its 1f937c815ee13bace1abeb2debe8ff8a8d72e306

JagerSprinkles commented 9 months ago

I installed 1f937c8 and after watching it for ~10 minutes it seems to be working as expected. Looks like there was a single update check in that time. So all looks good now!

Thank you for your work on this great integration!

heymoe commented 9 months ago

I just installed https://github.com/tomaae/homeassistant-truenas/commit/1f937c815ee13bace1abeb2debe8ff8a8d72e306 also and it looks like it working as expected on my side too.. Yay! Thanks @tomaae