Some checks failed
buildbot/nix-eval Build done.
buildbot/nix-build gitea:ops/nix-builder-autoscaler#checks.x86_64-linux.package-nix-builder-autoscaler Build done.
buildbot/nix-build gitea:ops/nix-builder-autoscaler#checks.x86_64-linux.package-default Build done.
buildbot/nix-build gitea:ops/nix-builder-autoscaler#checks.x86_64-linux.app-autoscalerctl Build done.
buildbot/nix-build gitea:ops/nix-builder-autoscaler#checks.x86_64-linux.app-default Build done.
buildbot/nix-build gitea:ops/nix-builder-autoscaler#checks.x86_64-linux.app-nix-builder-autoscaler Build done.
buildbot/nix-build gitea:ops/nix-builder-autoscaler#checks.x86_64-linux.nix-builder-autoscaler-pyright Build done.
buildbot/nix-build gitea:ops/nix-builder-autoscaler#checks.x86_64-linux.nix-builder-autoscaler-integration-tests Build done.
buildbot/nix-build gitea:ops/nix-builder-autoscaler#checks.x86_64-linux.nix-builder-autoscaler-ruff Build done.
buildbot/nix-build gitea:ops/nix-builder-autoscaler#checks.x86_64-linux.nix-builder-autoscaler-unit-tests Build done.
buildbot/nix-build gitea:ops/nix-builder-autoscaler#checks.x86_64-linux.package-buildbot-autoscale-ext Build done.
buildbot/nix-build Build done.
AWS does not allow cpu_options.nested_virtualization with spot instances. Add a second launch template (on-demand, cpu_options enabled) alongside the existing spot template. The autoscaler selects the template per-system based on nested_virtualization config. - RuntimeAdapter.launch_spot -> launch_instance(nested_virtualization=False) - EC2Runtime: selects spot or on-demand LT; raises misconfiguration error if on_demand_launch_template_id is empty when nested_virtualization=True - AwsConfig: add on_demand_launch_template_id field - SystemConfig: add nested_virtualization field - Scheduler: looks up system config to pass nested_virtualization flag - NixOS module: new aws.onDemandLaunchTemplateIdFile + capacity.nestedVirtualization options; assertion prevents enabling nestedVirtualization without the LT ID file
49 lines
1.5 KiB
Python
49 lines
1.5 KiB
Python
"""Abstract base class for runtime adapters."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from abc import ABC, abstractmethod
|
|
|
|
|
|
class RuntimeError(Exception):
|
|
"""Base error for runtime adapter failures.
|
|
|
|
Attributes:
|
|
category: Normalized error category for retry/classification logic.
|
|
"""
|
|
|
|
def __init__(self, message: str, category: str = "unknown") -> None:
|
|
super().__init__(message)
|
|
self.category = category
|
|
|
|
|
|
class RuntimeAdapter(ABC):
|
|
"""Interface for compute runtime backends (EC2, fake, etc.)."""
|
|
|
|
@abstractmethod
|
|
def launch_instance(
|
|
self, slot_id: str, user_data: str, *, nested_virtualization: bool = False
|
|
) -> str:
|
|
"""Launch an instance for slot_id. Return instance_id.
|
|
|
|
When nested_virtualization is True, an on-demand instance is launched using
|
|
the on-demand launch template. When False (default), a spot instance is launched.
|
|
"""
|
|
|
|
@abstractmethod
|
|
def describe_instance(self, instance_id: str) -> dict:
|
|
"""Return normalized instance info dict.
|
|
|
|
Keys: state, tailscale_ip (or None), launch_time.
|
|
"""
|
|
|
|
@abstractmethod
|
|
def terminate_instance(self, instance_id: str) -> None:
|
|
"""Terminate the instance."""
|
|
|
|
@abstractmethod
|
|
def list_managed_instances(self) -> list[dict]:
|
|
"""Return list of instances tagged ManagedBy=nix-builder-autoscaler.
|
|
|
|
Each entry has instance_id, state, slot_id (from AutoscalerSlot tag).
|
|
"""
|