Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement default hypervisor options on settings #573

Merged
merged 3 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/aleph/vm/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from subprocess import CalledProcessError, check_output
from typing import Any, Literal, NewType, Optional, Union

from aleph_message.models.execution.environment import HypervisorType
from pydantic import BaseSettings, Field, HttpUrl
from pydantic.env_settings import DotenvType, env_file_sentinel
from pydantic.typing import StrPath
Expand Down Expand Up @@ -255,6 +256,10 @@
ALLOCATION_TOKEN_HASH = "151ba92f2eb90bce67e912af2f7a5c17d8654b3d29895b042107ea312a7eebda"

ENABLE_QEMU_SUPPORT: bool = Field(default=False)
INSTANCE_DEFAULT_HYPERVISOR: Optional[HypervisorType] = Field(
default=HypervisorType.firecracker, # User Firecracker
description="Default hypervisor to use on running instances, can be Firecracker or QEmu",
)

# Tests on programs

Expand Down Expand Up @@ -391,6 +396,10 @@
network_interface=self.NETWORK_INTERFACE,
)

if not settings.ENABLE_QEMU_SUPPORT:
# If QEmu is not supported, ignore the setting and use Firecracker by default
settings.INSTANCE_DEFAULT_HYPERVISOR = HypervisorType.firecracker

Check warning on line 401 in src/aleph/vm/conf.py

View check run for this annotation

Codecov / codecov/patch

src/aleph/vm/conf.py#L401

Added line #L401 was not covered by tests

def display(self) -> str:
attributes: dict[str, Any] = {}

Expand Down
7 changes: 5 additions & 2 deletions src/aleph/vm/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,11 @@

@property
def hypervisor(self) -> HypervisorType:
# default to firecracker for retro compat
return self.message.environment.hypervisor or HypervisorType.firecracker
if self.is_program:
return HypervisorType.firecracker

Check warning on line 109 in src/aleph/vm/models.py

View check run for this annotation

Codecov / codecov/patch

src/aleph/vm/models.py#L109

Added line #L109 was not covered by tests

# Hypervisor setting is only used for instances
return self.message.environment.hypervisor or settings.INSTANCE_DEFAULT_HYPERVISOR

Check warning on line 112 in src/aleph/vm/models.py

View check run for this annotation

Codecov / codecov/patch

src/aleph/vm/models.py#L112

Added line #L112 was not covered by tests

@property
def becomes_ready(self) -> Callable[[], Coroutine]:
Expand Down