Delete Default API

Celery tasks for deleting llmclient API resources.

This module defines Celery tasks for deleting AWS and Kubernetes resources associated with an llmclient’s default API, including Route53 DNS records and ingress resources.

Main Tasks

  • delete_default_api(api_url, account_number, name):

    Deletes the default domain Route53 A record and Kubernetes ingress resources (ingress, certificate, secret) for an llmclient API.

Signals

  • pre_delete_default_api: Sent before API resource deletion begins.

  • post_delete_default_api: Sent after API resource deletion is completed.

Configuration

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

Logging

Task execution and resource deletion 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 delete llmclient API resources:

delete_default_api.delay(api_url, account_number, name)

raises Exception:

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

smarter.apps.llmclient.tasks.delete_default_api.delete_default_api(name, account_id, api_url)

Delete AWS and Kubernetes resources for a customer API.

Deletes the Kubernetes ingress, certificate, and secret associated with the llmclient’s named API url, which is of the form “https://{llmclient_name}.{account_number}.api_host_domain/”. Also deletes the default domain Route53 A record for the llmclient. Example api_url: https://stackademy-api.3141-5926-5359.alpha.api.ubc.smarter.sh/

This Celery task performs the following steps: 1. Sends a pre-delete signal for the API resources. 2. Logs the deletion request. 3. Extracts the domain name from the provided api_url. 4. Deletes the default domain Route53 A record for the llmclient. 5. Deletes Kubernetes ingress resources: ingress, certificate, and secret. 6. Logs the result of the deletion operations. 7. Sends a post-delete signal for the API resources.

Parameters:
  • llmclient_id (int) – The ID of the llmclient whose resources are to be deleted.

  • Signals

  • -------

  • pre_delete_default_api (django.dispatch.Signal) – Sent before the deletion of API resources begins.

  • post_delete_default_api (django.dispatch.Signal) – Sent after the deletion of API resources is completed.

Raises:

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