Create Custom Domain DNS Record

Celery tasks for llm_client custom domain DNS record management.

This module defines Celery tasks for creating and managing DNS records for llm_client custom domains using AWS Route53.

Main Tasks

  • create_custom_domain_dns_record(llm_client_custom_domain_id, record_name, record_type, record_value, record_ttl=600):

    Gets or creates a DNS record in an AWS Route53 hosted zone for an llm_client custom domain. Handles pre- and post-create signals, logging, and error retries.

Signals

  • pre_create_custom_domain_dns_record: Sent before a DNS record is created in the database.

  • post_create_custom_domain_dns_record: Sent after a DNS record is created in the database.

Configuration

Celery task behavior (retries, backoff, queue) is controlled by smarter_settings.

Logging

Task execution and DNS record creation are logged using the smarter logging library, with waffle switches for task and llm_client logging.

Usage

Import this module and call the Celery task as needed to asynchronously create or update DNS records for llm_client custom domains:

create_custom_domain_dns_record.delay(llm_client_custom_domain_id, record_name, record_type, record_value, record_ttl)

raises LLMClientCustomDomainNotFound:

If the LLMClientCustomDomain with the given ID does not exist.

raises Exception:

Any exception during task execution will trigger a retry according to Celery settings.

smarter.apps.llm_client.tasks.create_custom_domain_dns_record.create_custom_domain_dns_record(llm_client_custom_domain_id, record_name, record_type, record_value, record_ttl=600)

Get or create a DNS record in an AWS Route53 hosted zone for an llm_client custom domain.

This Celery task performs the following steps: 1. Sends a pre-create signal for the DNS record. 2. Logs the DNS record creation request. 3. Retrieves the LLMClientCustomDomain instance by ID. 4. Uses AWSRoute53 helper to get or create the DNS record in the specified hosted zone. 5. Updates or creates the LLMClientCustomDomainDNS record in the database. 6. Sends a post-create signal for the DNS record.

Parameters:
  • llm_client_custom_domain_id (int) – The primary key of the LLMClientCustomDomain instance.

  • record_name (str) – The DNS record name (e.g., ‘example.com.’).

  • record_type (str) – The DNS record type (e.g., ‘A’, ‘CNAME’).

  • record_value (str) – The value for the DNS record (e.g., IP address or CNAME target).

  • record_ttl (int, optional) – The TTL (time to live) for the DNS record, in seconds. Default is 600.

Returns:

  • dict – The DNS record details as returned by AWS Route53, for example:

    {

    ‘Name’: ‘example.com.’, ‘Type’: ‘A’, ‘TTL’: 300, ‘ResourceRecords’: [

    {‘Value’: ‘192.0.2.44’},

    ],

    }

  • Signals

  • ——-

  • pre_create_custom_domain_dns_record (django.dispatch.Signal) – Sent before the DNS record is created in the database.

  • post_create_custom_domain_dns_record (django.dispatch.Signal) – Sent after the DNS record is created in the database.

Raises:
  • LLMClientCustomDomainNotFound – If the LLMClientCustomDomain with the given ID does not exist.

  • Exception – Any exception raised during the creation process will trigger a retry according to Celery settings.