]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/tasks/cephfs/mount: use 'ip r' instead 'route'
authorKyr Shatskyy <kyrylo.shatskyy@clyso.com>
Tue, 11 Mar 2025 16:14:28 +0000 (17:14 +0100)
committerKyr Shatskyy <kyrylo.shatskyy@gmail.com>
Tue, 6 May 2025 11:47:04 +0000 (13:47 +0200)
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 <kyrylo.shatskyy@clyso.com>
(cherry picked from commit 46d7dd9952fa89497f9d781a24327b7e80954ca7)

qa/tasks/cephfs/mount.py

index 0060e7af2bf2a4f15adb605cf15551ebd2b4fbbe..c00ded82b56ae4f6e37116dc4ce02983aa76e0ef 100644 (file)
@@ -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