mirror of
https://github.com/Dvorinka/Containr.git
synced 2026-10-28 15:51:26 +00:00
feat(nodes): agent self-upgrade (#57)
POST /agents/:id/upgrade enqueues a self_upgrade command carrying the target platform, the sha256 the server computed over its bundled binary, and the server version. The agent downloads the replacement from the existing /api/agents/download/:platform endpoint, verifies the checksum, sanity-checks the new binary (--version), atomically swaps its own executable, reports the command result, then re-execs via syscall.Exec — no supervisor or restart plumbing required. Agents stamp main.version via ldflags at image build, expose --version, and now send version at register so node_agents.version refreshes on re-register (older agents without the field keep their stored value). The server rejects upgrades for offline nodes and for platforms with no bundled binary (linux-amd64/linux-arm64 ship in the image). Surfaces: nodes upgrade CLI, containr_nodes_upgrade MCP (confirm-gated), node-detail page button, OpenAPI. Verified live: v0.0.3 agent upgraded to v0.0.4 in place, re-registered with the new version; offline node returns 409 NODE_OFFLINE. Generated with [Devin](https://devin.ai) Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
dd5ce80ce2
commit
9de586f177
12 files changed
+337
-14
No files matched your search
@@ -5503,6 +5503,46 @@ paths:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
|
||||
/agents/{id}/upgrade:
|
||||
post:
|
||||
tags:
|
||||
- Agents
|
||||
summary: Upgrade the node agent
|
||||
description: >-
|
||||
Enqueues a `self_upgrade` command. The agent downloads its
|
||||
replacement binary from this server's bundled `/agents/download`
|
||||
endpoint, verifies the sha256, atomically swaps the executable, and
|
||||
re-execs itself — the command result reports before the process
|
||||
swaps. The node must be online, and the server must bundle a binary
|
||||
for the node's architecture (`linux-amd64`/`linux-arm64`).
|
||||
security:
|
||||
- bearerAuth: []
|
||||
parameters:
|
||||
- $ref: '#/components/parameters/AgentIdParam'
|
||||
responses:
|
||||
'202':
|
||||
description: Upgrade command enqueued
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
command: { type: object }
|
||||
platform: { type: string }
|
||||
version: { type: string }
|
||||
'404':
|
||||
description: Agent not found
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
'409':
|
||||
description: Node offline or no bundled binary for its architecture
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
|
||||
/agents/{id}/metrics:
|
||||
get:
|
||||
tags:
|
||||
|
||||
@@ -163,8 +163,15 @@ Take a node out of rotation or empty it entirely (admin):
|
||||
containr nodes cordon <id> # no new pins; running replicas stay
|
||||
containr nodes uncordon <id>
|
||||
containr nodes drain <id> # cordon + remove its containers + unpin services
|
||||
containr nodes upgrade <id> # agent pulls its replacement from the server, re-execs
|
||||
```
|
||||
|
||||
`nodes upgrade` swaps the agent binary for the one bundled in the running
|
||||
server image — the agent downloads it over the API, verifies the sha256 the
|
||||
server computed, sanity-checks it, atomically replaces its own executable,
|
||||
and re-execs. The node must be online and the server must ship a binary for
|
||||
its architecture (`linux-amd64`/`linux-arm64`).
|
||||
|
||||
## Service domains and access
|
||||
|
||||
A service can carry multiple hostnames; the default is mirrored to
|
||||
|
||||
Reference in new issue
Block a user