Deploy Default API

Celery tasks for deploying llmclient default API domains.

This module defines Celery tasks for deploying default API domains for llmclients, including the creation and verification of Route53 A records, Kubernetes ingress manifests, and certificate issuance.

Main Tasks

  • deploy_default_api(llmclient_id, with_domain_verification=True):

    Creates a default domain A record for an llmclient, manages ingress and certificate resources, and optionally verifies the domain.

Signals

  • pre_deploy_default_api: Sent before deployment of the default API begins.

  • post_deploy_default_api: Sent after deployment of the default API is completed.

  • llmclient_deployed: Sent when the llmclient is successfully deployed.

  • llmclient_deploy_failed: Sent when deployment fails.

  • llmclient_dns_verification_initiated: Sent when DNS verification is initiated.

  • llmclient_dns_verified: Sent when DNS verification succeeds.

  • llmclient_dns_failed: Sent when DNS verification fails.

  • llmclient_dns_verification_status_changed: Sent when DNS verification status changes.

Configuration

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

Logging

Task execution, resource creation, and deployment status 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 deploy an llmclient default API domain:

deploy_default_api.delay(llmclient_id, with_domain_verification=True)

raises LLMClient.DoesNotExist:

If the LLMClient with the given ID does not exist.

raises Exception:

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

smarter.apps.llmclient.tasks.deploy_default_api.deploy_default_api(llmclient_id, with_domain_verification=True)

Create a customer API default domain A record for an llmclient and manage deployment resources.

This Celery task performs the following steps: 1. Sends a pre-deploy signal for the llmclient API. 2. Logs the deployment request. 3. Retrieves the LLMClient instance by ID. 4. Creates a Route53 A record for the llmclient’s default domain. 5. Optionally creates and applies a Kubernetes ingress manifest for the domain. 6. Verifies ingress resources and certificate issuance. 7. Handles domain verification if requested. 8. Sends post-deploy and deployment status signals. 9. Notifies the account owner by email upon successful deployment.

Parameters:
  • llmclient_id (int) – The primary key of the LLMClient instance for which the default domain A record is being created.

  • with_domain_verification (bool, optional) – Whether to perform domain verification after deployment. Default is True.

  • Signals

  • -------

  • pre_deploy_default_api (django.dispatch.Signal) – Sent before deployment of the default API begins.

  • post_deploy_default_api (django.dispatch.Signal) – Sent after deployment of the default API is completed.

  • llmclient_deployed (django.dispatch.Signal) – Sent when the llmclient is successfully deployed.

  • llmclient_deploy_failed (django.dispatch.Signal) – Sent when deployment fails.

  • llmclient_dns_verification_initiated (django.dispatch.Signal) – Sent when DNS verification is initiated.

  • llmclient_dns_verified (django.dispatch.Signal) – Sent when DNS verification succeeds.

  • llmclient_dns_failed (django.dispatch.Signal) – Sent when DNS verification fails.

  • llmclient_dns_verification_status_changed (django.dispatch.Signal) – Sent when DNS verification status changes.

Raises:
  • LLMClient.DoesNotExist – If the LLMClient with the given ID does not exist.

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