lablink_allocator_service.operations¶
lablink_allocator_service.operations
¶
Background worker for on-demand OpenTofu apply/destroy operations.
Runs each operation on its own daemon thread, off the Flask request
thread, so a slow tofu apply/destroy doesn't hold an HTTP
connection open long enough to hit Cloudflare's edge timeout.
Attributes¶
logger = logging.getLogger(__name__)
module-attribute
¶
Classes¶
OperationsWorker(database)
¶
Submits apply/destroy jobs to run on a background thread.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
database
|
'OperationsDatabase'
|
OperationsDatabase instance for operation-status persistence. |
required |
Source code in packages/allocator/src/lablink_allocator_service/operations.py
Attributes¶
database = database
instance-attribute
¶
Methods:¶
start()
¶
Mark any operation left queued/running from a prior process as interrupted. Call once at allocator startup, before any new operation can be submitted, so a crash/restart mid-job is surfaced instead of hanging forever or being silently forgotten.
Source code in packages/allocator/src/lablink_allocator_service/operations.py
submit(op_type, fn, params=None, created_by=None)
¶
Queue a new operation and run it on a background thread.
Returns immediately after the operation row is created — does not
wait for fn to complete.
Raises:
| Type | Description |
|---|---|
OperationInProgress
|
propagated from database.create_operation if another operation is already queued/running. |