lablink_allocator_service.routes.public¶
lablink_allocator_service.routes.public
¶
Participant-facing routes: the landing page and seat assignment.
/api/request_vm is the only unauthenticated state-changing endpoint in
the allocator — it claims a seat by email. Rejoin is idempotent: an email
that already owns a running seat keeps it rather than consuming a second.
Attributes¶
bp = Blueprint('public', __name__)
module-attribute
¶
logger = logging.getLogger(__name__)
module-attribute
¶
Classes¶
Functions:¶
get_unassigned_instance_counts()
¶
Get the number of available (unassigned) VMs.
Returns the current count of VMs that are running and not yet assigned to a user.
Auth: None (health/monitoring).
Success Response:
- Code:
200 OK - Content:
Client Usage: Not used by the client service. Intended for external monitoring or UI components on the allocator to display the number of available VMs.
Source code in packages/allocator/src/lablink_allocator_service/routes/public.py
home()
¶
Landing page.
Renders index.html, the email form a participant submits to claim a
seat.
submit_vm_details()
¶
Claim a seat for a participant and redirect them to their desktop.
Auth: None — this is the only unauthenticated state-changing endpoint in the allocator.
Request Body: application/x-www-form-urlencoded
email(string, required): The participant's email address.
What it does:
- Idempotent rejoin. If this email already owns a running seat, it keeps that seat rather than consuming a second one.
- Atomic claim. Otherwise
assign_vmclaims a free seat withSELECT … FOR UPDATE SKIP LOCKED, so concurrent requesters cannot collide on one VM. An empty pool raises and returns503withno_seats.html. - Per-session prep. Mints a
session_idandbrowser_token, then rotates the KasmVNC password on the assigned client through that client's local agent. The claim has already committed by this point, so a rotation failure is compensated for, not rolled back: the seat is released and the VM flaggedUnhealthy. - Cookie + redirect. Signs a
lablink_sessioncookie bound to thesession_idand redirects toGET /desktop.
Success Response:
- Code:
303 See Other→/desktop, with thelablink_sessioncookie set.
Error Response:
- Code:
503 Service Unavailable—no_seats.htmlwhen the pool is empty, orrotation_failed.htmlwhen the assigned client could not be reached. On a rotation failure the seat is released and the VM flaggedUnhealthyso the participant isn't wedged on a dead machine. - Code:
200 OK—index.htmlre-rendered with an error ifemailis missing.
The participant supplies nothing but an email address.
Source code in packages/allocator/src/lablink_allocator_service/routes/public.py
32 33 34 35 36 37 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 | |