Queuing Changes

How the web server changes LLMHosts and their computes: it checks, then queues a task.

The manifest brokers, the api, the admin and the receivers call these functions, never the service’s launch, destroy or delete, nor the compute’s provisioner. Each checks what can be checked at once, so that an error is an error now, records what was queued as the status message (SAMLLMHostQueuedMessage), and queues a task once the current transaction commits. Only the infrastructure worker writes to the cluster and the cloud, so the app needs no more than a read-only Kubernetes Role (ADR-038, phase 3, issue #1080).

smarter.apps.llmhost.tasks.queue.queue_delete(llmhost, service=None)[source]

Queue delete_llmhost(), which destroys the LLMHost’s resources, then deletes it.

The LLMHost stays, with the message SAMLLMHostQueuedMessage.DELETE, until the task has destroyed what it deployed, so that a failure leaves it to delete again rather than resources that nothing tracks. The manifest broker’s delete and the api’s delete view call it.

Parameters:
  • llmhost (LLMHost) – The LLMHost.

  • service (LLMHostService | None) – The LLMHost service. A new one by default.

Raises:

LLMHostClusterError – if the LLMHost is deployed and the cluster is unavailable, as delete() would.

Return type:

None

smarter.apps.llmhost.tasks.queue.queue_destroy(llmhost, purge=False, service=None)[source]

Queue destroy_llmhost(), which destroys the LLMHost’s Kubernetes resources.

The manifest broker’s undeploy and the api’s undeploy view call it.

Parameters:
  • llmhost (LLMHost) – The LLMHost.

  • purge (bool) – Also delete its model volume.

  • service (LLMHostService | None) – The LLMHost service. A new one by default.

Raises:

LLMHostClusterError – if the cluster is unavailable, as the task would find it.

Return type:

None

smarter.apps.llmhost.tasks.queue.queue_launch(llmhost, service=None)[source]

Check that the LLMHost can be launched, then queue launch_llmhost().

The manifest broker’s deploy and the api’s deploy view call it. They only read the cluster: the infrastructure worker, which holds the Kubernetes write Role and the IAM role, makes every change.

Parameters:
  • llmhost (LLMHost) – The LLMHost.

  • service (LLMHostService | None) – The LLMHost service. A new one by default.

Return type:

LLMHostObservation

Returns:

What is known of the LLMHost now, with the message SAMLLMHostQueuedMessage.LAUNCH.

Raises:

LLMHostServiceError – if check_launch() refuses.

smarter.apps.llmhost.tasks.queue.queue_nodegroup_deletion(compute)[source]

Queue delete_llmhost_nodegroup(), which deletes the compute’s node group.

The pre_delete receiver of LLMHostCompute calls it, however the compute is deleted: the manifest broker, the admin, or the deletion of its owner. The task is given the node group’s name, which is all that the cloud needs, because the compute no longer exists when it runs.

Parameters:

compute (LLMHostCompute) – The LLMHostCompute, about to be deleted.

Return type:

None

smarter.apps.llmhost.tasks.queue.queue_reconcile(compute)[source]

Queue reconcile_llmhost_compute(), which gives the node group the nodes it needs.

The manifest broker’s deploy and the admin’s reconcile action call it.

Parameters:

compute (LLMHostCompute) – The LLMHostCompute.

Return type:

None