Verify Domain
Celery tasks for verifying llmclient domain DNS records.
This module defines Celery tasks for verifying that Internet domain names resolve to DNS records of the expected type, e.g. A, including signal handling, llmclient deployment status updates, and retry logic.
Main Tasks
- verify_domain(domain_name, record_type=”A”, llmclient_id=None, activate_llmclient=False, hosted_zone_id=None, task_id=None, attempt=0):
Attempts to verify that a domain name resolves to the expected DNS records, updating llmclient deployment status and sending verification signals.
A newly created DNS record can take hours to propagate. The task checks once, and if the domain
does not resolve yet, it schedules itself to check again in VERIFY_DOMAIN_INTERVAL seconds, up to
VERIFY_DOMAIN_MAX_ATTEMPTS times, rather than sleeping, so that it never blocks a Celery worker while
it waits. check_domain() is the single check, which deploy_default_api also uses.
Signals
pre_verify_domain: Sent before domain verification begins.
post_verify_domain: Sent after domain verification is completed.
llmclient_dns_verification_initiated: Sent when DNS verification is initiated.
llmclient_dns_failed: Sent when DNS verification fails.
llmclient_dns_verified: Sent when DNS verification succeeds.
Configuration
Celery task behavior (retries, backoff, queue) is controlled by smarter_settings. The task runs in the infrastructure queue, smarter_settings.infrastructure_tasks_celery_task_queue.
Logging
Task execution, verification attempts, and results are logged using the smarter logging library, with waffle switches for task and llmclient logging.
Usage
Import this module and call the Celery task as needed to asynchronously verify an llmclient domain:
verify_domain.delay(domain_name, record_type, llmclient_id, activate_llmclient, hosted_zone_id, task_id)
- raises Exception:
Any exception during task execution will trigger a retry according to Celery settings.
- class smarter.apps.llmclient.tasks.verify_domain.DomainCheck(*values)[source]
-
The result of one check of a domain.
- MISSING = 'missing'
The domain’s DNS record does not exist, so checking again cannot help.
- PENDING = 'pending'
The DNS record exists, but the domain does not resolve yet.
Check again later.
- VERIFIED = 'verified'
The domain’s DNS record exists, and the domain resolves.
- smarter.apps.llmclient.tasks.verify_domain.check_domain(domain_name, record_type='A', hosted_zone_id=None, task_id=None, llmclient=None)[source]
Check once that a domain’s DNS record exists, and that the domain resolves.
It sends llmclient_dns_verified when the domain resolves, and llmclient_dns_failed when it does not resolve yet. It does not wait: the caller checks again later.
- Parameters:
domain_name (
str) – The domain name, which infrastructure.dns.resolve_domain() has resolved.record_type (
str) – The DNS record type, e.g. A.hosted_zone_id (
str|None) – The DNS zone of the record, by default that of the environment’s api domain.task_id (
str|None) – The Celery task id, for logging and signals.llmclient (
LLMClient|None) – The LLMClient that the domain serves, if any, which is sent with the signals.
- Return type:
- smarter.apps.llmclient.tasks.verify_domain.verify_domain(domain_name, record_type='A', llmclient_id=None, activate_llmclient=False, hosted_zone_id=None, task_id=None, attempt=0)
Verify that an Internet domain name resolves, e.g. to its A records.
This Celery task checks that a domain name resolves to DNS records of the expected type, sending verification signals and updating llmclient deployment status as appropriate. If the domain does not resolve yet, it schedules itself to check again in VERIFY_DOMAIN_INTERVAL seconds, up to VERIFY_DOMAIN_MAX_ATTEMPTS times, rather than sleeping.
- Parameters:
domain_name (
str) – The domain name to verify.record_type (str, optional) – The DNS record type to verify (default is “A”).
llmclient_id (
int|None) – The id of the LLMClient associated with the domain, if any.activate_llmclient (
bool) – Whether to activate the llmclient upon successful verification. Default is False.hosted_zone_id (
str|None) – The id of the DNS zone to use for DNS lookups.task_id (
str|None) – The Celery task ID for logging and signal purposes.attempt (
int) – The number of checks already made. The task passes it when it schedules itself again.
- Return type:
- Returns:
bool or None – True if the domain is verified, False if it cannot be, and None if it will be checked again.
Signals
——-
pre_verify_domain (django.dispatch.Signal) – Sent before domain verification begins.
post_verify_domain (django.dispatch.Signal) – Sent after domain verification is completed.
llmclient_dns_verification_initiated (django.dispatch.Signal) – Sent when DNS verification is initiated.
llmclient_dns_failed (django.dispatch.Signal) – Sent when DNS verification fails.
llmclient_dns_verified (django.dispatch.Signal) – Sent when DNS verification succeeds.
- Raises:
Exception – Any exception raised during the verification process will trigger a retry according to Celery settings.