From 46d7dd9952fa89497f9d781a24327b7e80954ca7 Mon Sep 17 00:00:00 2001 From: Kyr Shatskyy Date: Tue, 11 Mar 2025 17:14:28 +0100 Subject: [PATCH] qa/tasks/cephfs/mount: use 'ip r' instead 'route' Some linux host may not have 'route' installed. So, maybe, prefer 'ip r' to find out which default gateway is configured. Addresses error if there is no net-tools installed on ubuntu remote hosts: route: command not found Signed-off-by: Kyr Shatskyy --- qa/tasks/cephfs/mount.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/qa/tasks/cephfs/mount.py b/qa/tasks/cephfs/mount.py index ddf6c2657a033..57b3096c3c512 100644 --- a/qa/tasks/cephfs/mount.py +++ b/qa/tasks/cephfs/mount.py @@ -296,12 +296,11 @@ class CephFSMountBase(object): self.client_remote.run(args=args, timeout=(5*60), omit_sudo=False) # Setup the NAT - p = self.client_remote.run(args=['route'], stderr=StringIO(), - stdout=StringIO(), timeout=(5*60)) - p = re.findall(r'default .*', p.stdout.getvalue()) - if p == False: + routes = self.client_remote.sh('ip r', timeout=(5*60)) + defaults = re.findall(r'^default .*', routes) + if defaults == False: raise RuntimeError("No default gw found") - gw = p[0].split()[7] + gw = defaults[0].split()[4] self.run_shell_payload(f""" set -e @@ -441,12 +440,12 @@ class CephFSMountBase(object): ip = IP(self.ceph_brx_net)[-2] mask = self.ceph_brx_net.split('/')[1] - p = self.client_remote.run(args=['route'], stderr=StringIO(), - stdout=StringIO(), timeout=(5*60)) - p = re.findall(r'default .*', p.stdout.getvalue()) - if p == False: + routes = self.client_remote.sh('ip r', timeout=(5*60)) + defaults = re.findall(r'^default .*', routes) + if defaults == False: raise RuntimeError("No default gw found") - gw = p[0].split()[7] + gw = defaults[0].split()[4] + self.run_shell_payload(f""" set -e sudo iptables -D FORWARD -o {gw} -i ceph-brx -j ACCEPT -- 2.39.5