From e9bd42478e9e158059bc21d17d10cc95d2d307b1 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Thu, 25 Sep 2025 09:33:41 +0200 Subject: [PATCH] fix: improve network isolation Use `check_output` instead of `check_call` in network isolation detection helper. It captures the output to stdout and avoid spurious warnings about missing commands. Add debug code to `run_network_isolation.sh` script. The script detects missing `ip` command and prints debug message + arguments on error. Signed-off-by: Christian Heimes --- src/fromager/external_commands.py | 2 +- src/fromager/run_network_isolation.sh | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/fromager/external_commands.py b/src/fromager/external_commands.py index 3ab57482..f23b20aa 100644 --- a/src/fromager/external_commands.py +++ b/src/fromager/external_commands.py @@ -39,7 +39,7 @@ def detect_network_isolation() -> None: cmd = network_isolation_cmd() if os.name == "posix": check = [*cmd, "true"] - subprocess.check_call(check, stderr=subprocess.STDOUT) + subprocess.check_output(check, stderr=subprocess.STDOUT) class NetworkIsolationError(subprocess.CalledProcessError): diff --git a/src/fromager/run_network_isolation.sh b/src/fromager/run_network_isolation.sh index c3e3d40b..dd6011da 100755 --- a/src/fromager/run_network_isolation.sh +++ b/src/fromager/run_network_isolation.sh @@ -22,11 +22,18 @@ if [ "$#" -eq 0 ]; then fi # bring loopback up -ip link set lo up +if command -v ip 2>&1 >/dev/null; then + ip link set lo up +else + echo "'ip' command is missing, cannot bring up loopback device for $@" >&2 + exit 2 +fi # set hostname to "localhost" if command -v hostname 2>&1 >/dev/null; then hostname localhost +else + echo "'hostname' command is missing, cannot set host name to 'localhost' for $@" >&2 fi # replace with command