I want to be able to inform our user that the device is updating the OS so they don’t power off the device or try to do work with it during the process. I am able to query for the OS update status by calling https://actions.balena-devices.com/v1/${RESIN_DEVICE_UUID}/resinhup. But I want to be able to track the % downloaded of the update and also the install progress after the reboot. Are there API calls that can give me this info?
Hello @jchoate2
You can use the supervisor API to track the progress of a download for a device from within a container. Please see the documentation here
Thanks! I had looked at that, but based on the documentation it looked like that was only for container updates. This will also report progress for OS updates?
I’ll check that with our supervisor developers.
Hi,
You can get the overall status and progress from the balenaCloud backend by doing the following curl request:
curl "https://api.balena-cloud.com/v6/device(uuid='$DEVICE_UUID')?\$select=overall_status,overall_progress" \
-H 'authorization: Bearer <TOKEN>'
The overall_status & overall_progress fields hold the values that our balenaCloud dashboard presents in the device status column, which also includes application updates etc
But while the device is updating its hostOS it will only hold related descriptions & related hostOS update progress.
A side note if you have used our backend api before, is that those two fields are not included in the result, unless they are explicitly provided in the $select part of the request.
Let us know how it works for you.
Kind regards,
Thodoris
This is perfect! One last question if I may - is there documentation on the possible values for status? I’ve seen ‘idle’ and ‘in_progress’ but wonder what the other possibilities are.
Hi Jon, I have looked into this and there is not documentation currently on the possible values for Host OS update statuses. But I have found the relevant lines in the Balena SDK that defines there. The possible values are ‘idle’, ‘in_progress’, ‘done’, ‘error’, and ‘configuring’. Here is also a link to the relevant lines in the source code:
Hmm… I ran the following script and then ran an OS update since I wanted to compare checking with the API vs. checking with the supervisor. Unfortunately I got this output:
2021-08-06 10:25:57 server percent: null
2021-08-06 10:25:57 supervisor percent: null
Here is the script I ran. Can you see any issue with it?
#!/usr/bin/env bash
while true; do
SERVER_STATUS=$(curl --silent "$BALENA_API_URL/v6/device(uuid='$BALENA_DEVICE_UUID')?\$select=overall_progress" -H "Authorization: Bearer ${BALENA_API_KEY}" | jq '.overall_progress')
SUPERVISOR_STATUS=$(curl --silent -X GET --header "Content-Type:application/json" "$BALENA_SUPERVISOR_ADDRESS/v1/device?apikey=$BALENA_SUPERVISOR_API_KEY" | jq '.download_progress')
echo "$(date "+%Y-%m-%d %H:%M:%S") server percent: $SERVER_STATUS" >> /data/progress.log
echo "$(date "+%Y-%m-%d %H:%M:%S") supervisor percent: $SUPERVISOR_STATUS" >> /data/progress.log
sleep 5
done
thanks again!
Hey @g-jon-choate, I don’t see any issues with your script upon first glance, but it might be worth adding set -x
before your while loop to see if the expected vars are set correctly?
Did you make any progress with this script? Let us know how it went!