Skip to content

Allocator should receive FQDN as environment variable instead of constructing URL from config #212

@eberrigan

Description

@eberrigan

Problem

The allocator service constructs its own URL from config file fields, but the infrastructure (Terraform) separately calculates the full URL/FQDN based on environment, DNS settings, and other factors. This mismatch causes client VMs to receive an incorrect allocator URL and fail to connect.

Expected Behavior

The allocator should use the same URL that was calculated by the infrastructure deployment and configured in Caddy/DNS.

Actual Behavior

Infrastructure calculates (in Terraform):

ci-test.lablink.lablink-template-testing.com

Allocator uses:

lablink-template-testing.com

Allocator logs show:

2025-10-15 22:28:35 - lablink_allocator_service.main - INFO - Using allocator URL: http://lablink-template-testing.com (protocol: http)

Root Cause

The allocator service reads the config file and constructs a URL from individual fields (e.g., dns.domain), but doesn't have access to:

  • The environment name
  • DNS pattern/subdomain logic
  • The final FQDN that Terraform calculated

This creates two sources of truth for the allocator URL:

  1. Infrastructure (Terraform) - calculates FQDN based on environment + DNS config
  2. Allocator service - constructs URL from config fields alone

Impact

  • Client VMs cannot connect to allocator (connectivity failure)
  • Multi-environment deployments to same domain don't work
  • Deployment configuration doesn't match runtime behavior

Reproduction

  1. Deploy allocator with any DNS configuration involving subdomains or environment-specific URLs
  2. Check allocator logs to see what URL it's using
  3. Compare to the FQDN that Terraform calculated (available in Terraform outputs)
  4. Create client VM and observe connection failure

Proposed Solution

Pass the computed FQDN as an environment variable to the allocator container:

In the infrastructure template's user_data.sh:

docker run -d -p 127.0.0.1:5000:5000 \
  -e ALLOCATOR_FQDN=${DOMAIN_NAME} \  # NEW: Pass FQDN from Terraform
  -e ALLOCATOR_PUBLIC_IP=${ALLOCATOR_PUBLIC_IP} \
  -e ENVIRONMENT=${RESOURCE_SUFFIX} \
  ...
  $IMAGE

Then update the allocator service to:

  1. Check for ALLOCATOR_FQDN environment variable first
  2. Fall back to constructing URL from config only if env var not set (backwards compatibility)

This ensures the allocator uses the same URL that the infrastructure configured, eliminating the dual source-of-truth problem.

Context

This issue was discovered during testing of the lablink-template repository's DNS configuration.

Template repository:

Note: The lablink-template is planning to simplify DNS/SSL configuration in future PRs (see DNS-SSL-SIMPLIFICATION-PLAN.md), but regardless of the final schema, the allocator should receive the computed FQDN rather than reconstructing it.

Related Discussion

This issue affects all deployment scenarios where the allocator URL differs from just the base domain field in config, including:

  • Multi-environment deployments (dev/test/prod subdomains)
  • Custom subdomain configurations
  • Future DNS configuration simplifications

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions