Can't update supervisor

Hey @sankyo.toshio so this is what we think what happened:

  • the device was already updated before from earlier versions, the latest one had supervisor 9.14.0
  • this time the update didn’t finish properly. The log is truncated in a way that we have never seen before, but it seems the OS was updated, while the supervisor was not
  • after reboot you went and manually edited the /etc/resin-supervisor/supervisor.conf , and restarted the supervisor service.
  • that pulled the new supervisor and started back up, it checked in the dashboard
  • the device has a timer that tries to run a supervisor update 15 minutes after boot, and then every 24h
  • because of the previous update, the backend still was set that the device should be running supervisor 9.14.0, so when the timer kicked in, the supervisor was downgraded.

… and that’s where your device was now, I believe.

So our comment would be:

  • never edit supervisor.conf manually, it pretty much never does what you want to do
  • updating the supervisor with update-resin-supervisor -t vX.Y.Z only works if the device was never updated before (thus the API doesn’t have a supervisor version stored for the device)
  • to get out of this state, would need to run something like this on your device, this time to fix things up. this works now, but not guaranteed to work in the future, if OS/supervisor update changes, please note :warning:

So, to fix up your device:

  1. remove the “new” supervisor version from the device, if it’s there, otherwise update-resin-supervisor won’t function properly (it’s something we wanna fix in the future)
balena rmi -f balena/armv7hf-supervisor:v10.2.2
  1. Update the API’s record for that device, to the right supervisor version, so e.g. for v10.2.2
TAG=v10.2.2

and then run this in the device’s host OS:

if [ -f "/mnt/boot/config.json" ]; then
  CONFIGJSON=/mnt/boot/config.json
elif [ -f "/mnt/conf/config.json" ]; then
  CONFIGJSON=/mnt/conf/config.json
fi
if [ -z "$TAG" ]; then
  echo "Please set TAG=vX.Y.Z supervisor version (e.g TAG=v6.3.5)"
elif [ -z "$CONFIGJSON" ]; then
  echo "Couldn't find config.json, cannot continue".
else
  APIKEY="$(jq -r '.apiKey // .deviceApiKey' "${CONFIGJSON}")"
  DEVICEID="$(jq -r '.deviceId' "${CONFIGJSON}")"
  API_ENDPOINT="$(jq -r '.apiEndpoint' "${CONFIGJSON}")"
  SLUG="$(jq -r '.deviceType' "${CONFIGJSON}")"
  SUPERVISOR_ID=$(curl -s "${API_ENDPOINT}/v3/supervisor_release?\$select=id,image_name&\$filter=((device_type%20eq%20'$SLUG')%20and%20(supervisor_version%20eq%20'$TAG'))&apikey=${APIKEY}" | jq -e -r '.d[0].id')
  echo "Extracted supervisor ID: $SUPERVISOR_ID"
  curl -s "${API_ENDPOINT}/v2/device($DEVICEID)?apikey=$APIKEY" -X PATCH -H 'Content-Type: application/json;charset=UTF-8' --data-binary "{\"supervisor_release\": \"$SUPERVISOR_ID\"}"
fi

If the result says “OK”, you should be able to run update-resin-supervisor (without any flags), and get an updated supervisor. :white_check_mark:

We can also do this for you, if you’d like, just enable susport access for the device you’d like us to check, and our support agents will take care of this! :bowing_man:

In general we are working on making OS/Supervisor updates more robust as well, and would recommend not editing things in the host OS without thorough underestanding what is going on…

What do you think?