lablink_allocator_service.routes.registration¶
lablink_allocator_service.routes.registration
¶
POST /api/v1/clients/register, GET /api/v1/clients/
Lazy-imports main inside views to avoid the module-load import cycle
(main imports this blueprint at startup). Mirrors the rationale behind
routes/desktop.py using current_app instead of importing main.
Attributes¶
bp = Blueprint('registration', __name__)
module-attribute
¶
Functions:¶
client_status(client_id)
¶
Get one client's status.
Auth: Bearer client_secret (that client's own secret).
Lets a registered client confirm the allocator still knows about it.
Source code in packages/allocator/src/lablink_allocator_service/routes/registration.py
list_clients()
¶
List registered clients for operator status views.
Auth: admin HTTP Basic — same gate as /admin/instances.
Returns only operator-safe columns (no secrets, no log blobs).
Source code in packages/allocator/src/lablink_allocator_service/routes/registration.py
register_client()
¶
Register a client machine and mint its credentials.
Auth: Register token (the one deployment-wide bearer credential).
Request Body: application/json
| Field | Required | Description |
|---|---|---|
hostname |
yes | The client's self-declared hostname, which becomes its client_id. Must start with a letter or digit and contain only letters, digits, dots, dashes and underscores (max 253 chars). |
machine_identity |
yes | Stable machine identifier, unique across the deployment. Re-registering the same identity replaces the old row rather than adding a seat. |
provider |
no | Defaults to aws. BYO clients send manual. |
provider_metadata |
no | Shape must match the deployment's configured manual.connectivity — lan_ip for lan_direct, overlay_hostname for mesh_overlay, reverse_tunnel: true for reverse_tunnel. A mismatch is rejected here rather than failing opaquely at assignment time. |
endpoint_url, gpu_present, gpu_model |
no | Reported by the client; all auto-detected by the CLI. |
Success Response:
- Code:
200 OK - Content: the client's credentials and the configuration it needs to start:
{
"client_id": "gpu-box-3",
"client_secret": "…",
"agent_token": "…",
"allocator_url": "https://lab.example.org",
"connectivity": "lan_direct",
"client_image": "ghcr.io/talmolab/lablink-client-base-image:latest",
"repository": "https://github.com/talmolab/sleap-tutorial-data.git",
"subject_software": "sleap",
"register_token": "…",
"startup_script_b64": "",
"startup_on_error": "continue",
"startup_max_attempts": 3,
"startup_base_delay_seconds": 30,
"startup_success_check_b64": "",
"monitoring": { "enabled": false }
}
client_secret is returned once and stored only as an argon2 hash.
Reverse-tunnel registrations additionally receive tunnel_url,
tunnel_path_prefix and tunnel_bind_addr, all minted by the
allocator.
Error Response:
- Code:
400 Bad Request— missing/invalidhostnameormachine_identity, or aprovider_metadatashape that doesn't match the configured connectivity. - Code:
401 Unauthorized— bad or missing register token.
Source code in packages/allocator/src/lablink_allocator_service/routes/registration.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 | |
report_overlay_hostname()
¶
Record the overlay hostname Tailscale actually assigned this client.
The name captured at registration is only what the client asked for.
tailscale up --hostname=X exits 0 even when an existing (possibly
offline) node already holds X, in which case Tailscale appends a numeric
suffix instead. The allocator dials the recorded name, so an
unreconciled rename sends every call to a dead node and the client is
marked Unhealthy forever (lablink#404).
Deliberately its own endpoint rather than a field on /api/vm-status:
that handler and the client's send_status are shared with the AWS
path, where a lost status POST is unrecoverable (see start.sh's own
comment and assign_vm's status='running' requirement). Nothing here runs
for an AWS or lan_direct client — start.sh only calls it inside its
TAILSCALE_AUTHKEY gate.
Lives in this module rather than vm_telemetry because this is where the
overlay_hostname contract is already enforced (see register_client's
expects_overlay check). Flat /api/ prefix to match the sibling
client-VM writes (/api/vm-status, /api/gpu_health,
/api/heartbeat) and to stay out of /api/v1/clients/<client_id>'s
path space.
Source code in packages/allocator/src/lablink_allocator_service/routes/registration.py
unregister_client(client_id)
¶
Best-effort caller-driven deregistration.
Auth: Bearer client_secret (the secret minted at register time).
Hard-deletes the row, even when useremail is set — the BYO
operator is voluntarily withdrawing the box, and the student's
session is already broken because the local container is going
away.