Verify Custom Domain

Celery tasks for verifying llm_client custom domains.

This module defines Celery tasks for verifying the NS records of AWS Route53 hosted zones for llm_client custom domains, including periodic re-verification, signal handling, and notification of account owners.

Main Tasks

  • verify_custom_domain(hosted_zone_id, sleep_interval=None, max_attempts=None):

    Periodically verifies the NS records of a hosted zone to ensure they match DNS records, updating verification status and notifying the account owner.

Signals

  • pre_verify_custom_domain: Sent before custom domain verification begins.

  • post_verify_custom_domain: Sent after custom domain verification is completed.

Configuration

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

Logging

Task execution, verification attempts, and results 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 verify an llm_client custom domain:

verify_custom_domain.delay(hosted_zone_id, sleep_interval, max_attempts)

raises LLMClientTaskError:

If the hosted zone data is not in the expected format.

raises Exception:

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

smarter.apps.llm_client.tasks.verify_custom_domain.verify_custom_domain(hosted_zone_id, sleep_interval=None, max_attempts=None)

Verify the NS records of an AWS Route53 hosted zone for a custom domain.

This Celery task periodically checks the NS records of a hosted zone to ensure they match DNS records, marking the custom domain as verified or not verified, and notifying the account owner of the result. Pre- and post-verification signals are sent, and all actions are logged.

Return type:

bool

Parameters:
  • hosted_zone_id (str) – The ID of the AWS Route53 hosted zone to verify.

  • sleep_interval (int, optional) – The interval in seconds to wait between verification attempts. Default is 1800 (30 minutes).

  • max_attempts (int, optional) – The maximum number of verification attempts. Default is calculated for 24 hours.

Returns:

  • bool – True if the hosted zone is verified, False otherwise.

  • Signals

  • ——-

  • pre_verify_custom_domain (django.dispatch.Signal) – Sent before custom domain verification begins.

  • post_verify_custom_domain (django.dispatch.Signal) – Sent after custom domain verification is completed.

Raises:
  • LLMClientTaskError – If the hosted zone data is not in the expected format.

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