lablink_allocator_service.client_session¶
lablink_allocator_service.client_session
¶
Per-session preparation: rotate the VNC password on the assigned client and persist per-session state on the clients row.
Called from /api/request_vm inside the seat-assignment transaction so rotation failure rolls back the assignment.
Attributes¶
ROTATE_BACKOFF_SECONDS = 1.5
module-attribute
¶
ROTATE_TIMEOUT = 5.0
module-attribute
¶
Classes¶
BrowserSessionTarget(ws_url, browser_credential)
dataclass
¶
RotationFailed
¶
Bases: RuntimeError
Raised when the per-session password rotation cannot be completed.
Functions:¶
prepare_browser_session(*, database, hostname, session_id, browser_token, agent_token, fallback_fn=None)
¶
Rotate the assigned client's VNC password and persist per-session columns on the VM row. Must be called inside the seat-assignment transaction so failures roll back.
agent_token is the deployment agent-control token (main.AGENT_TOKEN);
the client agent receives the same value as its AGENT_TOKEN env via the
OpenTofu user_data and validates it on every /api/session/start call.
Passed explicitly rather than read from env so this function has no
hidden global dependency for tests.
fallback_fn is an optional callable (hostname: str) -> str that
resolves the private IP when no stored LAN IP is found in the database.
Provider-specific connectivity strategies supply this (e.g.
AllocatorProxiedClientConnectivity passes an EC2 tag lookup).
When omitted and no stored IP exists, :exc:RotationFailed is raised.