tomaae / homeassistant-mikrotik_router

Mikrotik router integration for Home Assistant
Apache License 2.0
292 stars 48 forks source link

[Bug] RouterOS hangs on firmware update check - workaround #284

Closed ivanpavlina closed 1 year ago

ivanpavlina commented 1 year ago

Describe the issue

Hi, long time no see :) Hope you're doing great, I see you have been hard at work with this integration, great job, I'm loving it.

To business then - I've encountered a bug with routerOS which I doubt will be fixed soon, so I'm proposing a workaround from integration's side. Here's a issue which I reported on Mikrotik's forum: https://forum.mikrotik.com/viewtopic.php?t=196597 (well, that thread went to sh*t really fast haha)

Long story short, command /system/package/update check-for-updates sometimes hangs when internet is unavailable, which in turn breaks this component, it doesn't resume polling the data. Only if I restart homeassistant, or I go in winbox and hit the same command again through the terminal (or through GUI), it 'unblocks' previous command and integration starts working normally.

Catch-all fix for this would be to hardcode some max duration for execution to run, like: /system/package/update check-for-updates duration=10

This will limit execution of the command to 10 seconds.

Thank you, best regards.

How to reproduce the issue

Have RouterOS return "File not found" on package update check, command will hang indefinitely.

Software versions

Diagnostics data

In debug logs i see 2023-05-30 17:29:50.947 DEBUG (SyncWorker_5) [custom_components.mikrotik_router.mikrotikapi] API query: /system/package/update and no response, also no additional API query logs are produced until i manually 'fix' update check. Ping host lines are generating as expected.

tomaae commented 1 year ago

thats an interesting issue. reading that forum entry, it does not make sense for api query to wait for user input. its not cli. but yea, your RP hopefully fixes it.