Delete Default API
Celery tasks for deleting llmclient API resources.
This module defines Celery tasks for deleting the DNS and Kubernetes resources associated with an llmclient’s default API, including its DNS A record and ingress resources.
Main Tasks
- delete_default_api(api_url, account_number, name):
Deletes the default domain’s DNS 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(name=name, api_url=api_url, account_number=account_number)
- 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, api_url, account_number=None, account_id=None)
Delete the DNS and Kubernetes resources of 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’s DNS 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’s DNS 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:
name (
str) – The llmclient’s name.api_url (
str) – The llmclient’s default api url, e.g. https://example.3141-5926-5359.alpha.api.example.com/account_number (
str|None) – The account number of the llmclient’s account. The task is queued when the llmclient is deleted, which may be because its account is being deleted, so the account may no longer exist when the task runs. The caller passes the account number, which the task uses instead of looking the account up.account_id (
int|None) – Deprecated: the id of the llmclient’s account, which tasks queued by earlier versions pass. The account number is looked up from it if the account still exists, and is otherwise taken from the api url’s hostname.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.