lablink_allocator_service.reboot¶
lablink_allocator_service.reboot
¶
Automated VM reboot service.
Periodically checks for failed VMs and reboots them.
Assigned VMs get a warm reboot (plain sudo reboot) so the container
survives via its --restart unless-stopped policy. Unassigned VMs get
a cold reboot (cloud-init clean && sudo reboot) that recreates the
container from scratch. Both paths fall back to EC2 stop/start (always
cold) when SSH is unavailable.
Respects cooldown periods and maximum reboot attempt limits.
Attributes¶
logger = logging.getLogger(__name__)
module-attribute
¶
Classes¶
AutoRebootService(database, region='us-west-2', tofu_dir='', max_attempts=3, cooldown_seconds=300, check_interval_seconds=60, provider=None)
¶
Background service that monitors for failed VMs and reboots them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
database
|
VmDatabase
|
VmDatabase instance for querying/updating VM state. |
required |
region
|
str
|
AWS region where VMs are deployed. |
'us-west-2'
|
tofu_dir
|
str
|
Path to the OpenTofu directory (for SSH key retrieval). |
''
|
max_attempts
|
int
|
Maximum reboot attempts per VM before giving up. |
3
|
cooldown_seconds
|
int
|
Minimum seconds between reboots of the same VM. |
300
|
check_interval_seconds
|
int
|
How often to check for failed VMs. |
60
|
Source code in packages/allocator/src/lablink_allocator_service/reboot.py
Attributes¶
check_interval_seconds = check_interval_seconds
instance-attribute
¶
cooldown_seconds = cooldown_seconds
instance-attribute
¶
database = database
instance-attribute
¶
max_attempts = max_attempts
instance-attribute
¶
provider = provider
instance-attribute
¶
region = region
instance-attribute
¶
tofu_dir = tofu_dir
instance-attribute
¶
Methods:¶
start()
¶
Start the auto-reboot monitoring thread.
Source code in packages/allocator/src/lablink_allocator_service/reboot.py
stop()
¶
Stop the auto-reboot monitoring thread.