Check if a new version is available

Hi,
i wanted to know the best practice of detecting whether there is a new version available ?
our device is not alwayes connected to the internet, but when it does, we need to present to the user that there is a new version available, and update the containers when he approves.
whats the best way of doing that using balena os?

Daniel

Hello! So you want your users to decide if they want to update. Currently how are you handling the fleet update? Do you have pinned releases for the devices and ask them if they want to update and then manually pin the device to the new release?

currently its being updated to the latest always.
product decided that we should also ask the user if he wants to update.

i was wondering if there is an API to get all the versions available for the app or something like that.

Yes there is. You can get the releases of an app using the balena API, for more info you can check here https://www.balena.io/docs/reference/api/resources/release/ and then in your case if your user decides to update the device you can use https://www.balena.io/docs/reference/api/resources/device/#set-device-to-release to set the device to a release of your choosing.

@mbalamat thanks for the answer.
The best solution for me will be to lock the device, so updates will be downloaded, but will be installed only upon approval from user.
is that something the balena API provides? state of the current version in the device? (i didnt find in the documentation, but i can see in the dashboard that there is a state, so i assume there is such option)
also before i start the update, i want to perform few operations (also close communication so it cant be accessed)

Hi,
unfortunately it is currently not possible to pre-download updates. You can influence the update strategy using the RESIN_SUPERVISOR_UPDATE_STRATEGY environment variable: https://www.balena.io/docs/learn/deploy/release-strategy/update-strategies/ but none of them would let separate the download and the actual update.

***EDIT
I’m now using the API in the device /v1/device
and i’m getting some relevant fields, and i have a question about them:

“update_pending”:false,“update_failed”:false,“update_downloaded”:false,“status”:“Idle”,“download_progress”:null}

Are this parameters are global? or per service? in order to understand if there is an upload pending, do i need to question all the services or is it enough 1?

@mtoman
Is there a way i can mimic the behavior of the dashboard?
what i want to achieve on my app is starting to blink some LEDS on my device, the same time that on the dashboard i can see the “Downloading” phase in the services.
And stop the LEDS once it finished downloading and installing.

Is that possible? whats the best practice for that?

Daniel

Hi Daniel, the fields you refer to are documented at https://github.com/balena-io/balena-supervisor/blob/master/docs/API.md. They reflect supervisor state with respect to the whole application update. It seems to me you could achieve what you want by monitoring the status field.

thanks for the answer @alexgg, i do see that the status is not changing while its downloading, maybe there it acts differently when delta download is available? it keeps being idle although it was downloading.

i did notice that: update_pending is reflecting well.
any idea why the status is not changing?

Daniel.

Hey Daniel, yeah it is possible that the update_pending is true but the device has not started the download yet, as it might be waiting for the delta generation to be complete. Did you never see observe the status to be Downloading during an application update?

I never saw the status change to Downloading or Installing, always Idle.

Daniel.