lablink_allocator_service.conf.structured_config¶
lablink_allocator_service.conf.structured_config
¶
This module defines the database configuration structure for the LabLink Allocator Service.
Attributes¶
DB_HOST = 'localhost'
module-attribute
¶
DB_NAME = 'lablink_db'
module-attribute
¶
DB_PORT = 5432
module-attribute
¶
DB_USER = 'lablink'
module-attribute
¶
MISSING_SECRET = 'MISSING'
module-attribute
¶
PLACEHOLDER_SECRET_PREFIX = 'PLACEHOLDER_'
module-attribute
¶
VM_TABLE_NAME = 'vms'
module-attribute
¶
Classes¶
AllocatorConfig(image_tag='linux-amd64-latest')
dataclass
¶
Configuration for allocator service deployment.
This section is used by infrastructure deployment (OpenTofu) to specify which Docker image tag to use for the allocator service. The allocator service itself doesn't use this field, but it must be present in the schema to accept infrastructure configuration files.
Attributes:
| Name | Type | Description |
|---|---|---|
image_tag |
str
|
Docker image tag for the allocator service. Examples: "linux-amd64-latest-test", "linux-amd64-v1.2.3" |
AppConfig(admin_user=MISSING_SECRET, admin_password=MISSING_SECRET, region='us-west-2', admin_session_timeout_minutes=30)
dataclass
¶
Configuration for the LabLink Allocator Service application.
Attributes:
| Name | Type | Description |
|---|---|---|
admin_user |
str
|
The username for the admin user. |
admin_password |
str
|
The password for the admin user. |
region |
str
|
The AWS region where the service is deployed. |
admin_session_timeout_minutes |
int
|
Fixed duration cap for an admin's VNC troubleshooting session on an unassigned VM, after which the reservation is force-released. |
Attributes¶
admin_password = field(default=MISSING_SECRET)
class-attribute
instance-attribute
¶
admin_session_timeout_minutes = field(default=30)
class-attribute
instance-attribute
¶
admin_user = field(default=MISSING_SECRET)
class-attribute
instance-attribute
¶
region = field(default='us-west-2')
class-attribute
instance-attribute
¶
Config(deployment_name='', environment='prod', provider='aws', db=DatabaseConfig(), machine=MachineConfig(), app=AppConfig(), dns=DNSConfig(), eip=EIPConfig(), ssl=SSLConfig(), allocator=AllocatorConfig(), bucket_name='tf-state-lablink-allocator-bucket', startup_script=StartupConfig(), monitoring=MonitoringConfig(), manual=ManualConfig())
dataclass
¶
Configuration for the LabLink Allocator Service. This class aggregates the database, machine, and application configurations.
Attributes:
| Name | Type | Description |
|---|---|---|
deployment_name |
str
|
Unique name for this deployment (e.g., sleap-lablink). Used as prefix for all AWS resource names. Must be 3-32 characters, lowercase kebab-case. |
environment |
str
|
Deployment environment (dev, test, ci-test, prod). |
provider |
str
|
VM provisioning provider. One of:
- "aws": EC2 via OpenTofu (the existing behavior).
- "manual": no automated provisioning — BYO clients
register themselves via |
db |
DatabaseConfig
|
The database configuration. |
machine |
MachineConfig
|
The machine configuration. |
app |
AppConfig
|
The application configuration. |
dns |
DNSConfig
|
The DNS configuration. |
eip |
EIPConfig
|
The EIP management configuration. |
ssl |
SSLConfig
|
The SSL certificate configuration. |
allocator |
AllocatorConfig
|
The allocator deployment configuration. |
bucket_name |
str
|
The S3 bucket name for OpenTofu state. |
Attributes¶
allocator = field(default_factory=AllocatorConfig)
class-attribute
instance-attribute
¶
app = field(default_factory=AppConfig)
class-attribute
instance-attribute
¶
bucket_name = field(default='tf-state-lablink-allocator-bucket')
class-attribute
instance-attribute
¶
db = field(default_factory=DatabaseConfig)
class-attribute
instance-attribute
¶
deployment_name = field(default='')
class-attribute
instance-attribute
¶
dns = field(default_factory=DNSConfig)
class-attribute
instance-attribute
¶
eip = field(default_factory=EIPConfig)
class-attribute
instance-attribute
¶
environment = field(default='prod')
class-attribute
instance-attribute
¶
machine = field(default_factory=MachineConfig)
class-attribute
instance-attribute
¶
manual = field(default_factory=ManualConfig)
class-attribute
instance-attribute
¶
monitoring = field(default_factory=MonitoringConfig)
class-attribute
instance-attribute
¶
provider = field(default='aws')
class-attribute
instance-attribute
¶
ssl = field(default_factory=SSLConfig)
class-attribute
instance-attribute
¶
startup_script = field(default_factory=StartupConfig)
class-attribute
instance-attribute
¶
DNSConfig(enabled=False, terraform_managed=True, domain='', zone_id='')
dataclass
¶
Configuration for DNS and domain setup.
This class defines DNS settings for Route 53 hosted zones and records. DNS can be disabled entirely, or configured with external DNS providers.
Attributes:
| Name | Type | Description |
|---|---|---|
enabled |
bool
|
Whether DNS is enabled. If False, only IP addresses are used. |
terraform_managed |
bool
|
Whether OpenTofu creates/destroys DNS records. - True: OpenTofu manages Route53 DNS records (creates and destroys) - False: External DNS management (CloudFlare, manual Route53, etc.) |
domain |
str
|
Full domain name for the allocator (e.g., "lablink.sleap.ai", "test.lablink.sleap.ai"). Required when enabled=true. Supports sub-subdomains for environment separation. |
zone_id |
str
|
Optional Route53 hosted zone ID. If provided, skips zone lookup. Use this when zone lookup finds the wrong zone (e.g., parent vs subdomain). |
DatabaseConfig(password='lablink')
dataclass
¶
EIPConfig(strategy='dynamic')
dataclass
¶
Configuration for Elastic IP management strategy.
Attributes:
| Name | Type | Description |
|---|---|---|
strategy |
str
|
EIP allocation strategy. Options: - "persistent": Reuse existing tagged EIP across deployments - "dynamic": Create new EIP for each deployment |
MachineConfig(machine_type='g4dn.xlarge', repository=None, image='ghcr.io/talmolab/lablink-client-base-image:latest', ami_id='', software='sleap')
dataclass
¶
Configuration for the machine used in the LabLink Allocator Service. This class defines the machine type, repository, image, AMI ID, and software to be used.
Attributes:
| Name | Type | Description |
|---|---|---|
machine_type |
str
|
The type of the machine to be used. |
repository |
Optional[str]
|
The repository URL for the machine image. |
image |
str
|
The Docker image ID to be used for the machine. |
ami_id |
str
|
AMI for client VMs. Empty (the default) resolves AWS's Deep Learning Base AMI for the deployment's region, which carries Docker, the NVIDIA driver and nvidia-container-runtime — all three required, since the client's boot script installs none of them. Set this to use a specific image, such as LabLink's leaner published one where that exists. |
software |
str
|
The software to be installed on the machine. |
Attributes¶
ami_id = field(default='')
class-attribute
instance-attribute
¶
image = field(default='ghcr.io/talmolab/lablink-client-base-image:latest')
class-attribute
instance-attribute
¶
machine_type = field(default='g4dn.xlarge')
class-attribute
instance-attribute
¶
repository = field(default=None)
class-attribute
instance-attribute
¶
software = field(default='sleap')
class-attribute
instance-attribute
¶
ManualConfig(connectivity='lan_direct', overlay_tailnet='', participant_exposure='none', public_hostname='')
dataclass
¶
Configuration for the manual provider's client connectivity and participant-exposure strategy.
Attributes:
| Name | Type | Description |
|---|---|---|
connectivity |
str
|
How the browser reaches a manual client's KasmVNC desktop. Options: - "lan_direct": the browser opens a WebSocket straight to the client's LAN IP (default; requires client on the allocator's own LAN). - "mesh_overlay": the client joins a Tailscale tailnet; the allocator reaches it via that overlay and proxies the byte path through its own nginx, same as the AWS path. For clients that aren't on the allocator's LAN (e.g. a Run:AI-hosted workload). |
overlay_tailnet |
str
|
The Tailscale tailnet's MagicDNS domain suffix (e.g. "example.ts.net"), used to resolve a registered client's overlay hostname, and/or the allocator's own Funnel-published hostname. Required when connectivity is "mesh_overlay" or participant_exposure is "tailscale_funnel"; ignored otherwise. |
participant_exposure |
str
|
How participants (not clients) reach the allocator when it isn't on their LAN. Independent of connectivity — an admin can have lan_direct clients and still want off-LAN participants, or vice versa. Options: - "none": unchanged, LAN-only (default). - "tailscale_funnel": publish the allocator's HTTP port to the public internet via the tailnet named by overlay_tailnet, using the same tailscale sidecar connectivity="mesh_overlay" already provisions (reused, not a second sidecar). - "cloudflare_tunnel": publish the allocator at public_hostname via a Cloudflare Tunnel the admin created in their own Cloudflare account. Requires a domain whose nameservers point at Cloudflare (free-plan "full setup" — partial/CNAME setup is Business-tier, subdomain zones are Enterprise, so an institutional domain cannot be used). NOTE: unlike Funnel, which terminates TLS on this machine, Cloudflare decrypts all traffic at its edge — admin logins and participant desktop streams included. |
public_hostname |
str
|
The public hostname participants open, e.g. "lab.smithlab.org". Required when participant_exposure is "cloudflare_tunnel"; ignored otherwise. Deliberately generic: any future exposure mode with an admin-chosen hostname reuses this field rather than adding a vendor-named one. |
Attributes¶
connectivity = field(default='lan_direct')
class-attribute
instance-attribute
¶
overlay_tailnet = field(default='')
class-attribute
instance-attribute
¶
participant_exposure = field(default='none')
class-attribute
instance-attribute
¶
public_hostname = field(default='')
class-attribute
instance-attribute
¶
MonitoringConfig(enabled=False, subject_window_patterns=list(), process_allowlist=(lambda: ['sleap-train', 'sleap-track', 'sleap-label'])(), watch_dir='/home/client/Desktop', sample_interval_seconds=2, push_interval_seconds=60)
dataclass
¶
Attributes¶
enabled = False
class-attribute
instance-attribute
¶
process_allowlist = field(default_factory=lambda: ['sleap-train', 'sleap-track', 'sleap-label'])
class-attribute
instance-attribute
¶
push_interval_seconds = 60
class-attribute
instance-attribute
¶
sample_interval_seconds = 2
class-attribute
instance-attribute
¶
subject_window_patterns = field(default_factory=list)
class-attribute
instance-attribute
¶
watch_dir = '/home/client/Desktop'
class-attribute
instance-attribute
¶
SSLConfig(provider='letsencrypt', email='', certificate_arn='')
dataclass
¶
Configuration for SSL/TLS certificate management.
Attributes:
| Name | Type | Description |
|---|---|---|
provider |
str
|
SSL provider. Options: - "none": HTTP only, no SSL - "letsencrypt": Automatic SSL via Caddy + Let's Encrypt - "cloudflare": CloudFlare proxy handles SSL (requires terraform_managed=false) - "acm": AWS Certificate Manager (requires ALB, certificate_arn) |
email |
str
|
Email address for Let's Encrypt notifications (required when provider="letsencrypt") |
certificate_arn |
str
|
AWS ACM certificate ARN (required when provider="acm") |
StartupConfig(enabled=False, path='', on_error='continue', max_attempts=3, base_delay_seconds=30, success_check='')
dataclass
¶
Configuration for startup behavior of the allocator service. Attributes: enabled (bool): Whether startup script execution is enabled. path (str): Path to the startup script to be executed. on_error (str): Behavior on startup script error. Options: - "continue": Log the error and continue startup. - "fail": Abort startup on error. max_attempts (int): Total attempts to run the startup script before giving up (1 = no retry). base_delay_seconds (int): Base delay for exponential backoff between retries; doubles each attempt, plus jitter. success_check (str): Optional shell command run after the script exits 0 to verify success beyond its own exit code. Empty string disables the check (success = exit code only).
Attributes¶
base_delay_seconds = field(default=30)
class-attribute
instance-attribute
¶
enabled = field(default=False)
class-attribute
instance-attribute
¶
max_attempts = field(default=3)
class-attribute
instance-attribute
¶
on_error = field(default='continue')
class-attribute
instance-attribute
¶
path = field(default='')
class-attribute
instance-attribute
¶
success_check = field(default='')
class-attribute
instance-attribute
¶
Functions:¶
is_unresolved_secret(value)
¶
True if value is an unfilled sentinel rather than a real credential.
Covers the schema default (MISSING) and the template's
PLACEHOLDER_* literals. A placeholder reaching a running allocator
means the substitution never happened — the deploy workflow is the only
thing that performs it, so a local tofu apply (a documented path
in lablink-template) bakes the literal straight into the instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
The configured credential to inspect. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True when the value is a sentinel and must not be trusted. |