Delete Default API
Celery tasks for deleting llm_client API resources.
This module defines Celery tasks for deleting AWS and Kubernetes resources associated with an llm_client’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 llm_client 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 llm_client logging.
Usage
Import this module and call the Celery task as needed to asynchronously delete llm_client 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.llm_client.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 llm_client’s named API url, which is of the form “https://{llm_client_name}.{account_number}.api_host_domain/”. Also deletes the default domain Route53 A record for the llm_client. 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 llm_client. 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:
llm_client_id (int) – The ID of the llm_client 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.