truenas: migrate client from deprecated REST to JSON-RPC 2.0 over WebSocket #1
Loading…
Reference in a new issue
No description provided.
Delete branch "truenas-jsonrpc-migration"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
TrueNAS removes the /api/v2.0 REST API in 26.04. REST was stateless, so the
12s poll loop re-authenticated on every request (~130k auths/day, tripping the
deprecation alarm). Switch app/truenas.py to JSON-RPC 2.0 over a single
persistent, authenticated wss://.../api/current connection: requests are
multiplexed by JSON-RPC id and demuxed by one background reader task, so auth
happens once per connection instead of per request.
Method mappings verified against a live TrueNAS SCALE 25.10.4 box:
disk.query, core.get_jobs, system.info, disk.temperatures, core.job_abort,
disk.wipe. The smart.test.* namespace was removed in 25.10; those two methods
are the SSH-superseded fallback and now raise cleanly (caller already skips).
disk.wipe is a @job method: over JSON-RPC a job call returns the integer job id
immediately (verified via pool.import_find -> core.get_jobs), same as the old
REST endpoint. Documented that contract and guard it — an untracked destructive
wipe is worse than a loud failure.
Reads keep the exponential-backoff retry; writes fail loud rather than risk a
double-execute on a dropped socket.
Concurrency: each socket owns its own pending-waiter map, so a superseded reader
running its cleanup after a reconnect can only fail its own in-flight calls and
never clobbers the current connection's pending requests.
Also:
state so dev-against-mock keeps working; disk.wipe creates a trackable job so
get_job() resolves. REST routes stay for /health + /debug.
transitively via uvicorn[standard], so no lockfile regen).
wipe_disk job-id contract, and stale-reader isolation (fake socket, no network).
Verified: full suite 158/158 · live read-only smoke test of the new client
against TrueNAS 25.10.4 (disks, temps, jobs, system.info) succeeded.
Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com