Skip to content

Commit

Permalink
Fix: Errors in network interface manipulation were invisible
Browse files Browse the repository at this point in the history
Solution: Always use `check=True` to force errors in `subprocess.run` to raise an error.
  • Loading branch information
hoh committed Mar 6, 2024
1 parent b497e9a commit 0b5e90e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/aleph/vm/network/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ async def create(self):
if not ip_command:
raise FileNotFoundError("ip command not found")

run([ip_command, "tuntap", "add", self.device_name, "mode", "tap"])
run([ip_command, "tuntap", "add", self.device_name, "mode", "tap"], check=True)
run(
[
ip_command,
Expand All @@ -67,7 +67,8 @@ async def create(self):
str(self.host_ip.with_prefixlen),
"dev",
self.device_name,
]
],
check=True,
)
ipv6_gateway = self.host_ipv6
run(
Expand All @@ -78,9 +79,10 @@ async def create(self):
str(ipv6_gateway),
"dev",
self.device_name,
]
],
check=True,
)
run([ip_command, "link", "set", self.device_name, "up"])
run([ip_command, "link", "set", self.device_name, "up"], check=True)
if self.ndp_proxy:
await self.ndp_proxy.add_range(self.device_name, ipv6_gateway.network)
logger.debug(f"Network interface created: {self.device_name}")
Expand All @@ -92,4 +94,4 @@ async def delete(self) -> None:
await asyncio.sleep(0.1) # Avoids Device/Resource busy bug
if self.ndp_proxy:
await self.ndp_proxy.delete_range(self.device_name)
run(["ip", "tuntap", "del", self.device_name, "mode", "tap"])
run(["ip", "tuntap", "del", self.device_name, "mode", "tap"], check=True)

0 comments on commit 0b5e90e

Please sign in to comment.