Open Balena Version Issues

I got some issues regarding the preloading proccess with the CLI open Balena and the raspberrypi 4.

If i use the latest balena cli, the preload process wont work with the openBalena server with following Error message:

Request error: <!DOCTYPE html>
156<html lang="en">
157<head>
158<meta charset="utf-8">
159<title>Error</title>
160</head>
161<body>
162<pre>Cannot GET /device/v3/432f7b760fe54d5e87eeff707562fa5e/state</pre>
163</body>
164</html>
165 (BalenaRequestError)

If i use an older CLI the device cannot start without internet connection with following error message:

Cannot migrate from v2 apps.json without Internet connectivity. Please use balenaCLI v13.5.1+ for offline preload support.

Could you please fix that issue or give me a hint what raspberrypi4 image is fitting to latest openBalena version and CLI version: “13.3.1”

Thanks a lot for investigating.

Hello,

thanks for this report. Are you able to do a balena login and a balena whoami to check that the balena cli is connected to your openBalena instance?
Can you also please share the command that you use to invoke the preloading?

Thanks and best regards
Harald

I get the the same kind of error with 15.0.3 and 15.1.0,

<pre>Cannot GET /device/v3/128d740e01f9459db29481bc5dc4ebff/state</pre>

when running: balena preload raspberrypi3-2.113.4+rev1-v14.9.1.img --fleet maestro --add-certificate ../balena-ca.crt --splash-image /path/to/logo.jpg

Signed in and able to get other API data. balena whoami works:

== ACCOUNT INFORMATION
USERNAME: admin

The un-GET-able device corresponds to a newly created Open Balena record:

open-balena-api’s logs do not register anything related to that apart from a simple 404:

cf67e16cd6e1 api[1195]: 2023-03-17T00:07:07.531Z 67.161.104.3 a/2 GET /device/v3/f9ad0f3bdc40455499f01e6e6707a420/state 404 3286.784ms balena-sdk/16.28.0

I tried preloading with 12.55.11,

> balena preload raspberrypi3-2.113.4+rev1-v14.9.1.img --fleet maestro --add-certificate ../balena-ca.crt --splash-image /path/to/logo.jpg --dont-check-arch
Building Docker preloader image. [========================] 100%
| Checking that the image is a writable file
| Finding a free tcp port
| Checking if the image is an edison zip archive
| Creating preloader container
- Starting preloader container
\ Fetching application admin/maestro
\ Reading image information
? Select a release current
\ Fetching application 1
/ Estimating required additional space
/ Resizing partitions and waiting for dockerd to start
Pulling 4 images [========================] 100%
/ Cleaning up temporary files

and reproduced the second problem: the device boots, but only the supervisor runs and its logs include the following:

info]    Reporting initial state, supervisor version and API info
[info]    Attempting to load any preloaded applications
[error]   LogBackend: server responded with status code: 401
[debug]   Cannot migrate from v2 apps.json without Internet connectivity. Please use balenaCLI v13.5.1+ for offline preload support.
[event]   Event: Loading preloaded apps failed {"error":{"message":"Cannot migrate from v2 apps.json without Internet connectivity. Please use balenaCLI v13.5.1+ for offline preload support.","stack":"Error: Cannot migrate from v2 apps.json without Internet connectivity. Please use balenaCLI v13.5.1+ for offline preload support.\n    at /usr/src/app/dist/app.js:22:53255\n    at processTicksAndRejections (node:internal/process/task_queues:96:5)\n    at async /usr/src/app/dist/app.js:22:52804\n    at async Promise.all (index 0)\n    at async fromV2TargetApps (/usr/src/app/dist/app.js:22:52694)\n    at async exports.fromV2AppsJson (/usr/src/app/dist/app.js:10:15063)\n    at async exports.loadTargetFromFile (/usr/src/app/dist/app.js:10:16586)\n    at async Object.exports.loadInitialState (/usr/src/app/dist/app.js:10:1290)\n    at async Promise.all (index 0)\n    at async Supervisor.init (/usr/src/app/dist/app.js:22:108604)"}}
[event]   Event: Device bootstrap success {}
[info]    Reporting initial configuration
[error]   Error reporting initial configuration, will retry HTTPError: Response code 404 (Not Found)
[error]         at Request.<anonymous> (/usr/src/app/dist/87.app.js:1:165558)
[error]       at Object.onceWrapper (node:events:628:26)
[error]       at Request.emit (node:events:525:35)
[error]       at Request._onResponseBase (/usr/src/app/dist/87.app.js:1:153943)
[error]       at processTicksAndRejections (node:internal/process/task_queues:96:5)
[error]       at async Request._onResponse (/usr/src/app/dist/87.app.js:1:154509)
[info]    VPN connection is active.

However, the device is not actually offline: I configured it with ethernet, it registered with the server, and I am able to remotely tunnel in and ping google.com. So, preloading with an older CLI appears incompatible with newer open-balena, 3.8.2 in this case.

Focusing on the former issue, it appears that the new device record is being created just to learn the target state (as discussed in Issues Using Balena Preload), and would be deleted if the device state succeeded. A request to the v2 version of the endpoint succeeds:

$ curl -X GET --header "Content-Type:application/json" --header "Authorization: Bearer $BALENA_TOKEN" --data '{"method": "GET"}' "https://<DOMAIN>/device/v2/7019154e897c4ba5b79e557af8d5a4a7/state"
{"local":{"name":"cold-madness","config":{"BALENA_SUPERVISOR_OVERRIDE_LOCK":"1","RESIN_SUPERVISOR_POLL_INTERVAL":"600000"},"apps":{"1":{"releaseId":17, [etc]

While open-balena-api does have v3 get-state code, a full pull/rebuild of the latest open-balena gets me balena/open-balena-api:v0.192.4, whose src/ only includes routes/state-get-v2.ts.

UPDATE:
Found that the container was being launched by a second, older installation with open-balena 3.6.0. Upgrading that to 3.8.2 did bring support for the v3 state endpoint and allowed the preload to complete. The latest open-balena version might have been earlier when this thread was started.