From 2ec36095693b7ca2dd1f54e70ac563d4f889cb3a Mon Sep 17 00:00:00 2001 From: Loic Dachary Date: Thu, 16 Oct 2014 08:39:15 -0700 Subject: [PATCH] cli: CEPH_ARGS must be before injectargs It is incorrect to append the content of CEPH_ARGS to the argument list when running injectargs. For instance if CEPH_ARGS='--log-file the.log' \ ./ceph tell osd.0 injectargs --no-osd_debug_op_order translates into ./ceph tell osd.0 injectargs --no-osd_debug_op_order \ --log-file the.log it ends up changing the log file of osd.0 which is probably unintended. Instead CEPH_ARGS is inserted before injectargs and it translates into: ./ceph tell osd.0 --log-file the.log \ injectargs --no-osd_debug_op_order Signed-off-by: Loic Dachary --- qa/workunits/cephtool/test.sh | 3 +++ src/ceph.in | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/qa/workunits/cephtool/test.sh b/qa/workunits/cephtool/test.sh index 9da3603d764d5..d06c45a7ede82 100755 --- a/qa/workunits/cephtool/test.sh +++ b/qa/workunits/cephtool/test.sh @@ -157,6 +157,9 @@ function expect_config_value() function test_mon_injectargs() { + CEPH_ARGS='--mon_debug_dump_location the.dump' ./ceph tell osd.0 injectargs --no-osd_debug_op_order >& $TMPFILE || return 1 + check_response "osd_debug_op_order = 'false'" + ! grep "the.dump" $TMPFILE || return 1 ceph tell osd.0 injectargs '--osd_debug_op_order --osd_debug_drop_ping_probability 444' >& $TMPFILE || return 1 check_response "osd_debug_drop_ping_probability = '444' osd_debug_op_order = 'true'" ceph tell osd.0 injectargs --no-osd_debug_op_order >& $TMPFILE || return 1 diff --git a/src/ceph.in b/src/ceph.in index ebcfb2edce107..4e8901b3015c8 100755 --- a/src/ceph.in +++ b/src/ceph.in @@ -526,8 +526,11 @@ def ping_monitor(cluster_handle, name): def main(): ceph_args = os.environ.get('CEPH_ARGS') if ceph_args: - sys.argv.extend(ceph_args.split()) - + if "injectargs" in sys.argv: + i = sys.argv.index("injectargs") + sys.argv = sys.argv[:i] + ceph_args.split() + sys.argv[i:] + else: + sys.argv.extend(ceph_args.split()) parser, parsed_args, childargs = parse_cmdargs() if parsed_args.version: -- 2.39.5