From 871ac6b3764f02791798f6d5b01f5ee85957e1eb Mon Sep 17 00:00:00 2001 From: Xiubo Li Date: Wed, 10 Jun 2020 05:25:30 -0400 Subject: [PATCH] qa/tasks/vstart_runner.py: disable the ns unsharing if using localhost If the -l option is specified in : $ MDS=3 MON=3 MGR=1 OSD=3 ../src/vstart.sh -n -l The ceph cluster will use the localhost IP address as the mon host, and then in the network namespace container the ceph-fuse daemon couldn't connect to it. Fixes: https://tracker.ceph.com/issues/45342 Signed-off-by: Xiubo Li --- qa/tasks/vstart_runner.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/qa/tasks/vstart_runner.py b/qa/tasks/vstart_runner.py index d4d19afcc63..86a5a89f3f8 100644 --- a/qa/tasks/vstart_runner.py +++ b/qa/tasks/vstart_runner.py @@ -592,6 +592,16 @@ def safe_kill(pid): else: raise +def mon_in_localhost(config_path="./ceph.conf"): + """ + If the ceph cluster is using the localhost IP as mon host, will must disable ns unsharing + """ + with open(config_path) as f: + for line in f: + local = re.match(r'^\s*mon host\s*=\s*\[((v1|v2):127\.0\.0\.1:\d+,?)+\]', line) + if local: + return True + return False class LocalKernelMount(KernelMount): def __init__(self, ctx, test_dir, client_id=None, @@ -1613,6 +1623,9 @@ def exec_test(): if opt_create_cluster_only: return + if opt_use_ns and mon_in_localhost() and not opt_create_cluster: + raise RuntimeError("cluster is on localhost; '--usens' option is incompatible. Or you can pass an extra '--create' option to create a new cluster without localhost!") + # List of client mounts, sufficient to run the selected tests clients = [i.__str__() for i in range(0, max_required_clients)]