lablink_allocator_service.utils.config_helpers¶
lablink_allocator_service.utils.config_helpers
¶
Configuration helper functions for building URLs and determining settings.
Attributes¶
CANONICAL_URL_FILENAME = 'allocator-url'
module-attribute
¶
logger = logging.getLogger(__name__)
module-attribute
¶
Functions:¶
canonical_base_url(request)
¶
Return the allocator's public base URL, without a trailing slash.
Prefers the operator-supplied canonical URL file over request.host_url.
Behind Tailscale Funnel, host_url reports http:// even for requests
that arrived over Funnel's HTTPS: manual-provider deployments only support
ssl.provider: none, so :func:should_use_https is false and the
X-Forwarded-Proto gate stays shut — and Funnel does not inject that
header anyway, so there is no in-request signal to detect it. Clients that
take the resulting http:// URL at face value only get a 302 from
Funnel, which downgrades their POSTs to GET and surfaces as 405s.
The file is read per request rather than cached, because the CLI writes it
after docker compose up (Funnel can only be enabled once the container
is running), and the allocator must pick it up without a restart.
Falls back to request.host_url when the file is missing, empty, or does
not contain an http(s) URL — so the AWS/nginx topology, where ProxyFix
already yields the right scheme, is completely unaffected.
Source code in packages/allocator/src/lablink_allocator_service/utils/config_helpers.py
get_allocator_url(cfg, allocator_ip)
¶
Build the allocator URL based on configuration.
Priority order: 1. ALLOCATOR_FQDN environment variable (set by OpenTofu) 2. DNS configuration from config 3. IP address fallback
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cfg
|
DictConfig
|
Hydra/OmegaConf configuration object. |
required |
allocator_ip
|
str
|
Public IP address of allocator. |
required |
Returns:
| Type | Description |
|---|---|
Tuple[str, str]
|
Tuple of (base_url, protocol) |
Examples:
ALLOCATOR_FQDN environment variable: ("https://test.lablink.sleap.ai", "https")
DNS enabled + Let's Encrypt SSL: ("https://test.lablink.sleap.ai", "https")
DNS disabled + No SSL: ("http://52.40.142.146", "http")
Source code in packages/allocator/src/lablink_allocator_service/utils/config_helpers.py
is_self_signed_ssl(cfg)
¶
Check if the deployment uses a self-signed TLS cert.
Used by BYO onboarding to decide whether the rendered
lablink client register command should include --insecure.