Skip to content

Commit 8fb1ee1

Browse files
committed
Fix: Path to sevctl was not from settings
1 parent 834ae4d commit 8fb1ee1

File tree

4 files changed

+18
-10
lines changed

4 files changed

+18
-10
lines changed

src/aleph/vm/conf.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,7 @@ def check(self):
388388
assert (
389389
check_system_module("kvm_amd/parameters/sev_es") == "Y"
390390
), "SEV-ES feature isn't enabled, enable it in BIOS"
391-
assert is_command_available("sevctl"), "Command `sevctl` not found, run `cargo install sevctl`"
392-
391+
assert self.SEV_CTL_PATH.is_file(), f"File not found {self.SEV_CTL_PATH}"
393392
assert self.ENABLE_QEMU_SUPPORT, "Qemu Support is needed for confidential computing and it's disabled, "
394393
"enable it setting the env variable `ENABLE_QEMU_SUPPORT=True` in configuration"
395394

src/aleph/vm/orchestrator/supervisor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def run():
163163

164164
# Store sevctl app singleton only if confidential feature is enabled
165165
if settings.ENABLE_CONFIDENTIAL_COMPUTING:
166-
sev_client = SevClient(settings.CONFIDENTIAL_DIRECTORY)
166+
sev_client = SevClient(settings.CONFIDENTIAL_DIRECTORY, settings.SEV_CTL_PATH)
167167
app["sev_client"] = sev_client
168168
# TODO: Review and check sevctl first initialization steps, like (sevctl generate and sevctl provision)
169169

src/aleph/vm/sevclient.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,27 @@
44

55

66
class SevClient:
7-
def __init__(self, sev_dir: Path):
7+
sev_dir: Path
8+
sev_ctl_executable: Path
9+
certificates_dir: Path
10+
certificates_archive: Path
11+
12+
def __init__(self, sev_dir: Path, sev_ctl_executable: Path):
813
self.sev_dir = sev_dir
14+
self.sev_ctl_executable = sev_ctl_executable
915
self.certificates_dir = sev_dir / "platform"
1016
self.certificates_dir.mkdir(exist_ok=True, parents=True)
1117
self.certificates_archive = self.certificates_dir / "certs_export.cert"
1218

13-
async def sevctl_cmd(self, *args) -> bytes:
19+
async def sev_ctl_cmd(self, *args) -> bytes:
20+
"""Run a command of the 'sevctl' tool."""
1421
return await run_in_subprocess(
15-
["sevctl", *args],
22+
[self.sev_ctl_executable, *args],
1623
check=True,
1724
)
1825

1926
async def get_certificates(self) -> Path:
2027
if not self.certificates_archive.is_file():
21-
_ = await self.sevctl_cmd("export", str(self.certificates_archive))
28+
_ = await self.sev_ctl_cmd("export", str(self.certificates_archive))
2229

2330
return self.certificates_archive

tests/supervisor/test_views.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ async def test_about_certificates_missing_setting(aiohttp_client):
135135
settings.ENABLE_CONFIDENTIAL_COMPUTING = False
136136

137137
app = setup_webapp()
138-
app["sev_client"] = SevClient(Path().resolve())
138+
app["sev_client"] = SevClient(Path().resolve(), Path("/opt/sevctl").resolve())
139139
client = await aiohttp_client(app)
140140
response: web.Response = await client.get("/about/certificates")
141141
assert response.status == 400
@@ -160,7 +160,7 @@ async def test_about_certificates(aiohttp_client):
160160
) as export_mock:
161161
with tempfile.TemporaryDirectory() as tmp_dir:
162162
app = setup_webapp()
163-
sev_client = SevClient(Path(tmp_dir))
163+
sev_client = SevClient(Path(tmp_dir), Path("/opt/sevctl"))
164164
app["sev_client"] = sev_client
165165
# Create mock file to return it
166166
Path(sev_client.certificates_archive).touch(exist_ok=True)
@@ -170,4 +170,6 @@ async def test_about_certificates(aiohttp_client):
170170
assert response.status == 200
171171
is_file_mock.assert_has_calls([call(), call()])
172172
certificates_expected_dir = sev_client.certificates_archive
173-
export_mock.assert_called_once_with(["sevctl", "export", str(certificates_expected_dir)], check=True)
173+
export_mock.assert_called_once_with(
174+
["/opt/sevctl", "export", str(certificates_expected_dir)], check=True
175+
)

0 commit comments

Comments
 (0)