Skip to content

Commit 2e7edd2

Browse files
committed
mod: remove unused code: ping, instance wait_for_init
1 parent 70a6810 commit 2e7edd2

File tree

3 files changed

+2
-67
lines changed

3 files changed

+2
-67
lines changed

src/aleph/vm/controllers/firecracker/instance.py

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,7 @@
2121
from aleph.vm.hypervisors.firecracker.microvm import setfacl
2222
from aleph.vm.network.interfaces import TapInterface
2323
from aleph.vm.storage import create_devmapper, create_volume_file
24-
from aleph.vm.utils import (
25-
HostNotFoundError,
26-
NotEnoughDiskSpaceError,
27-
check_disk_space,
28-
ping,
29-
run_in_subprocess,
30-
)
24+
from aleph.vm.utils import NotEnoughDiskSpaceError, check_disk_space, run_in_subprocess
3125

3226
from .executable import (
3327
AlephFirecrackerExecutable,
@@ -120,30 +114,6 @@ async def setup(self):
120114
),
121115
)
122116

123-
async def wait_for_init(self) -> None:
124-
"""Wait for the init process of the instance to be ready."""
125-
assert self.enable_networking and self.tap_interface, f"Network not enabled for VM {self.vm_id}"
126-
127-
ip = self.get_ip()
128-
if not ip:
129-
msg = "Host IP not available"
130-
raise ValueError(msg)
131-
132-
ip = ip.split("/", 1)[0]
133-
134-
attempts = 30
135-
timeout_seconds = 2
136-
137-
for attempt in range(attempts):
138-
try:
139-
await ping(ip, packets=1, timeout=timeout_seconds)
140-
return
141-
except HostNotFoundError:
142-
if attempt < (attempts - 1):
143-
continue
144-
else:
145-
raise
146-
147117
async def create_snapshot(self) -> CompressedDiskVolumeSnapshot:
148118
"""Create a VM snapshot"""
149119
volume_path = await create_volume_file(self.resources.message_content.rootfs, self.resources.namespace)

src/aleph/vm/controllers/qemu/instance.py

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
from aleph.vm.network.interfaces import TapInterface
3232
from aleph.vm.resources import HostGPU
3333
from aleph.vm.storage import get_rootfs_base_path
34-
from aleph.vm.utils import HostNotFoundError, ping, run_in_subprocess
34+
from aleph.vm.utils import run_in_subprocess
3535

3636
logger = logging.getLogger(__name__)
3737

@@ -231,36 +231,12 @@ async def start(self):
231231
# Start via systemd not here
232232
raise NotImplementedError()
233233

234-
async def wait_for_init(self) -> None:
235-
"""Wait for the init process of the instance to be ready."""
236-
assert self.enable_networking and self.tap_interface, f"Network not enabled for VM {self.vm_id}"
237-
238-
ip = self.get_ip()
239-
if not ip:
240-
msg = "Host IP not available"
241-
raise ValueError(msg)
242-
ip = ip.split("/", 1)[0]
243-
244-
attempts = 30
245-
timeout_seconds = 2
246-
247-
for attempt in range(attempts):
248-
try:
249-
await ping(ip, packets=1, timeout=timeout_seconds)
250-
return
251-
except HostNotFoundError:
252-
if attempt < (attempts - 1):
253-
continue
254-
else:
255-
raise
256-
257234
async def start_guest_api(self):
258235
pass
259236

260237
async def stop_guest_api(self):
261238
pass
262239

263-
264240
async def teardown(self):
265241
if self.enable_networking:
266242
teardown_nftables_for_vm(self.vm_id)

src/aleph/vm/utils/__init__.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -177,17 +177,6 @@ class HostNotFoundError(Exception):
177177
pass
178178

179179

180-
async def ping(host: str, packets: int, timeout: int):
181-
"""
182-
Waits for a host to respond to a ping request.
183-
"""
184-
185-
try:
186-
await run_in_subprocess(["ping", "-c", str(packets), "-W", str(timeout), host], check=True)
187-
except subprocess.CalledProcessError as err:
188-
raise HostNotFoundError() from err
189-
190-
191180
async def is_pinging(host: str, packets: int, timeout: int) -> bool:
192181
"""
193182
Try to ping an ip, return true if host respond, fale otherwise

0 commit comments

Comments
 (0)