I’d like to get some input on how to implement some potentially tricky update timing/scheduling logic.
Here’s the device behavior I am going for:
- updates are downloaded to the device automatically
- installation is scheduled for an appropriate day and time (either automatically by our software or via user input) - could be days/weeks in the future
- there’s also an “Update Now” button that runs the update when it’s clicked
- there’s also a button to disable automatic updates; updates would then only happen when the aforementioned “Update Now” button is clicked
Here is what I am thinking for the implementation:
Set mender config variables to something like:
"StateScriptRetryIntervalSeconds": 30, "StateScriptRetryTimeoutSeconds" : 604800
Have a Download_Leave script that causes my custom scheduler (either software-only or incl. asking for user input) to run. This script keeps returning 21 (for retry-later) until the scheduled time comes, and then returns 0 to proceed with the update.
The above StateScriptRetryTimeoutSeconds would allow scheduling the update for up to a week into the future.
If the user clicks “update now” at any time prior to the scheduled time, the Download_Leave script would just return 0 the next time it runs and the update would happen.
So far so good, I think - though if you see any issues with that, please let me know.
How could I deal with a scenario where either no suitable time is found, or the user disables automatic updates?
In this scenario, either the user chooses to disable automatic updates, or no suitable time to run the update is found before StateScriptRetryTimeoutSeconds is up.
The update thus gets marked as failed.
At this point, how could I implement an “Update Now” button on the client?
It seems like I should tell the mender client to go to the ArtifactInstall state when the “Update Now” button is clicked at this point (and again, noting that this command should originate on the client rather than on the server / mender dashboard). Is there a way to do that?
It looks like I could get the download manually via the Device / Deployments API, but that I’d kind of be bypassing the state machine by doing that.
Is there a good way for me to implement this functionality?