lablink_allocator_service.db.schedules¶
lablink_allocator_service.db.schedules
¶
Persistence for the scheduled_destructions table.
A standalone table: no foreign key to, and no shared columns with, the VM table. The scheduled job clears VM rows (see scheduler.py), but that is job behavior, not schema coupling — this class touches only its own table.
Shares the connection pool with the other classes in this package (see db.pool.make_pool) rather than opening a second one, since POOL_MAX_SIZE is tuned for the allocator's total connection budget.
Attributes¶
logger = logging.getLogger(__name__)
module-attribute
¶
Classes¶
ScheduleDatabase(pool)
¶
Persistence for the scheduled_destructions table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pool
|
A psycopg2 connection pool, shared with the other db classes. |
required |
Source code in packages/allocator/src/lablink_allocator_service/db/schedules.py
Methods:¶
cancel_scheduled_destruction(schedule_id)
¶
Cancel a scheduled destruction.
Source code in packages/allocator/src/lablink_allocator_service/db/schedules.py
create_scheduled_destruction(schedule_name, destruction_time, recurrence_rule=None, created_by=None, notification_enabled=True, notification_hours_before=1)
¶
Create a scheduled destruction entry and return its ID.
Raises:
| Type | Description |
|---|---|
ValueError
|
If a schedule with the same name already exists |
RuntimeError
|
If database operation fails |
Source code in packages/allocator/src/lablink_allocator_service/db/schedules.py
get_all_scheduled_destructions(status=None)
¶
Get all scheduled destructions, optionally filtered by status.
Source code in packages/allocator/src/lablink_allocator_service/db/schedules.py
get_scheduled_destruction(schedule_id)
¶
Get scheduled destruction by ID.
Source code in packages/allocator/src/lablink_allocator_service/db/schedules.py
update_scheduled_destruction_status(schedule_id, status, execution_result=None)
¶
Update destruction execution status.