Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Auto-Update Blueprint: Repeating Failed Updates #13

Open
alexbeer2048 opened this issue Sep 5, 2024 · 3 comments
Open

Issue with Auto-Update Blueprint: Repeating Failed Updates #13

alexbeer2048 opened this issue Sep 5, 2024 · 3 comments

Comments

@alexbeer2048
Copy link

I encountered an issue with the Auto-Update blueprint where, when an update fails (in my case an addon update via HACS), the script does not skip to the next item. Instead, it waits 1 hour and then attempts the same update again, repeating this process each hour.

My situation:

I have two Shellies Discovery addons that won’t update due to my current HA Core version. So it's necessary to update the core first.

As I understand it, the Auto update script will try to update addons first, then core items, then OS, and so on.

What I expect is that my case the sequence would go like this:

  1. Attempt to update "Shellies Discovery Gen2" addon (fails due to core version)
  2. Attempt to update "Shellies Discovery" addon (will also fail)
  3. Update HA Core
    (And if all goes well the remaining updates would be applied on the next day/update schedule)

But whats happening looking at the logbook and traces is this:

  1. Attempt to update "Shellies Discovery Gen2" addon (fails due to core version)
  2. Retry updating "Shellies Discovery Gen2" addon (fails again) --> 1-hour pause
  3. Retry updating "Shellies Discovery Gen2" addon (fails again) --> 1-hour pause
  4. Then proceeds to restart HA
    Likely because of the pending restart from the HACS update from the day before, but it shows that the script wasn't crashing and restarting in between update attempts.

I'm not sure why it stopped after the third time, but I believe it was because the update schedule window which I set for testing happened to be 2 hours long.

Investigation:
I examined the script and found a potential cause.


In this line, the script selects the top entry from the pending_update_list as entity_id for the update.install action, but if the update fails, this entry will still be in the list in the next iteration, because the update state for that entity also doesn't change.

As a result, if an update fails (as in my case, due to version restrictions), the script keeps looping over the same update indefinitely, or until the scheduled update window ends.

Unfortunately, my HA scripting skills are not up there yet, so I'm not sure how to fix this.

However, one potential solution could involve creating a local list variable (outside the loop) to track updates that have already been attempted. This list could be used as an additional filter in subsequent iterations, ensuring that each update is only tried once during a single script execution.


Btw, I understand I could resolve this manually by updating the core, but I wanted to report what I believe is a bug so that we can continue to improve this very useful script 😊
@edwardtfn
Copy link
Owner

I will take a look at that tomorrow. Thanks for the detailed report. 🙂

@edwardtfn
Copy link
Owner

This is challenging to duplicate...
Do you still have any case of those failing updates? If so, could you please share it's state and attributes?
I wanna see how the info about the failure is stored.

Please make sure you have removed any sensitive info before sharing. 😉

@alexbeer2048
Copy link
Author

No, I ended up updating the core module manually, and as expected, everything is working normally now.

I did save a trace of the automation as a JSON file, but it’s almost 3,000 lines long, and I was hoping to avoid having to clean it up for posting 😅. It’s probably easier to reproduce the issue than to go through the trace anyway.

To reproduce, try installing Shellies Discovery Gen2 and Shellies Discovery via HACS, and make sure to install (or downgrade to) the versions of HA Core and the addons that I mentioned above next to the red arrows.

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

No branches or pull requests

2 participants