From 4e2a1e006c253e831716d0bd07a7a70c21d815de Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Fri, 15 May 2026 18:19:41 +0100 Subject: [PATCH] test-network: retry networkctl status in wait_operstate() networkctl status may transiently fail right after start_networkd() because networkd has not yet picked up the freshly-created link from the kernel. The retry loop in wait_operstate() did not catch the resulting subprocess.CalledProcessError, so the test aborted on the first attempt instead of retrying for the configured timeout. Observed in TEST-85-NETWORK-NetworkdBridgeTests, subtest test_bridge_configure_without_carrier[no-slave]: [ 19.600156] systemd-networkd-tests.py[526]: Failed to issue io.systemd.Network.Link.Describe() varlink call: Invalid argument [ 53.124982] systemd[1]: systemd-networkd.service: Changed start -> running [ 53.336167] systemd-networkd-tests.py[526]: ERROR: test_bridge_configure_without_carrier (__main__.NetworkdBridgeTests.test_bridge_configure_without_carrier) (test='no-slave') [ 53.336167] systemd-networkd-tests.py[526]: self.wait_operstate('bridge99', operstate=r'(no-carrier|routable)', setup_state=None, setup_timeout=30) [ 53.336167] systemd-networkd-tests.py[526]: subprocess.CalledProcessError: Command '['/usr/bin/networkctl', '-n', '0', 'status', 'bridge99']' returned non-zero exit status 1. Co-developed-by: Claude Opus 4.7 (cherry picked from commit 446b0393ff06bf5065af48601eb28f6d56616c19) (cherry picked from commit eacfec289e0bd5b2ff21fd5a906bec418a086353) --- test/test-network/systemd-networkd-tests.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index 8835559de30..176285c6fa5 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -1226,7 +1226,13 @@ class Utilities(): if not link_exists(link): time.sleep(0.5) continue - output = networkctl_status(link) + try: + output = networkctl_status(link) + except subprocess.CalledProcessError: + # networkctl status may transiently fail e.g. when networkd has not + # yet picked up the link from the kernel. Retry until the timeout. + time.sleep(0.5) + continue if re.search(rf'(?m)^\s*State:\s+{operstate}\s+\({setup_state}\)\s*$', output): return True time.sleep(0.5)