mirror of
https://github.com/ceph/ceph
synced 2024-12-28 06:23:08 +00:00
Merge pull request #2733 from dachary/wip-9372-injectargs
cli: do not parse injectargs arguments twice Reviewed-by: Dan Mick <dan.mick@inktank.com>
This commit is contained in:
commit
9a12467a9c
@ -426,19 +426,19 @@ useful for increasing/decreasing logging output, enabling/disabling debug
|
||||
settings, and even for runtime optimization. The following reflects runtime
|
||||
configuration usage::
|
||||
|
||||
ceph {daemon-type} tell {id or *} injectargs '--{name} {value} [--{name} {value}]'
|
||||
ceph tell {daemon-type}.{id or *} injectargs --{name} {value} [--{name} {value}]
|
||||
|
||||
Replace ``{daemon-type}`` with one of ``osd``, ``mon`` or ``mds``. You may apply
|
||||
the runtime setting to all daemons of a particular type with ``*``, or specify
|
||||
a specific daemon's ID (i.e., its number or letter). For example, to increase
|
||||
debug logging for a ``ceph-osd`` daemon named ``osd.0``, execute the following::
|
||||
|
||||
ceph osd tell 0 injectargs '--debug-osd 20 --debug-ms 1'
|
||||
ceph tell osd.0 injectargs --debug-osd 20 --debug-ms 1
|
||||
|
||||
In your ``ceph.conf`` file, you may use spaces when specifying a
|
||||
setting name. When specifying a setting name on the command line,
|
||||
ensure that you use an underscore or hyphen (``_`` or ``-``) between
|
||||
terms (e.g., ``debug osd`` becomes ``debug-osd``).
|
||||
terms (e.g., ``debug osd`` becomes ``--debug-osd``).
|
||||
|
||||
|
||||
Viewing a Configuration at Runtime
|
||||
|
@ -292,11 +292,11 @@ MDS Subsystem
|
||||
|
||||
Change configuration parameters on a running mds. ::
|
||||
|
||||
ceph mds tell {mds-id} injectargs '--{switch} {value} [--{switch} {value}]'
|
||||
ceph tell mds.{mds-id} injectargs --{switch} {value} [--{switch} {value}]
|
||||
|
||||
Example::
|
||||
|
||||
ceph mds tell 0 injectargs '--debug_ms 1 --debug_mds 10'
|
||||
ceph tell mds.0 injectargs --debug_ms 1 --debug_mds 10
|
||||
|
||||
Enables debug messages. ::
|
||||
|
||||
|
@ -1079,7 +1079,7 @@ the default as of v0.73). To make this warning go away, you have two options:
|
||||
For the change to take effect, you will need to restart the monitors, or
|
||||
apply the option to running monitors with::
|
||||
|
||||
ceph -- tell mon.\* injectargs --no-mon-warn-on-legacy-crush-tunables
|
||||
ceph tell mon.\* injectargs --no-mon-warn-on-legacy-crush-tunables
|
||||
|
||||
|
||||
A few important points
|
||||
|
@ -277,7 +277,7 @@ The admin socket command enables you to show and set your configuration at
|
||||
runtime. See `Viewing a Configuration at Runtime`_ for details.
|
||||
|
||||
Additionally, you can set configuration values at runtime directly (i.e., the
|
||||
admin socket bypasses the monitor, unlike ``ceph {daemon-type} tell {id}
|
||||
admin socket bypasses the monitor, unlike ``ceph tell {daemon-type}.{id}
|
||||
injectargs``, which relies on the monitor but doesn't require you to login
|
||||
directly to the host in question ).
|
||||
|
||||
|
@ -40,14 +40,14 @@ in to a host with a running daemon and execute the following::
|
||||
To activate Ceph's debugging output (*i.e.*, ``dout()``) at runtime, use the
|
||||
``ceph tell`` command to inject arguments into the runtime configuration::
|
||||
|
||||
ceph tell {daemon-type}.{daemon id or *} injectargs '--{name} {value} [--{name} {value}]'
|
||||
ceph tell {daemon-type}.{daemon id or *} injectargs --{name} {value} [--{name} {value}]
|
||||
|
||||
Replace ``{daemon-type}`` with one of ``osd``, ``mon`` or ``mds``. You may apply
|
||||
the runtime setting to all daemons of a particular type with ``*``, or specify
|
||||
a specific daemon's ID (i.e., its number or letter). For example, to increase
|
||||
debug logging for a ``ceph-osd`` daemon named ``osd.0``, execute the following::
|
||||
|
||||
ceph tell osd.0 injectargs '--debug-osd 0/5'
|
||||
ceph tell osd.0 injectargs --debug-osd 0/5
|
||||
|
||||
The ``ceph tell`` command goes through the monitors. If you cannot bind to the
|
||||
monitor, you can still make the change by logging into the host of the daemon
|
||||
|
@ -438,11 +438,11 @@ You have quorum
|
||||
|
||||
Either inject the debug option into the monitor you want to debug::
|
||||
|
||||
ceph tell mon.FOO injectargs '--debug_mon 10/10'
|
||||
ceph tell mon.FOO injectargs --debug_mon 10/10
|
||||
|
||||
or into all monitors at once::
|
||||
|
||||
ceph tell mon.* injectargs '--debug_mon 10/10'
|
||||
ceph tell mon.* injectargs --debug_mon 10/10
|
||||
|
||||
No quourm
|
||||
|
||||
|
@ -155,6 +155,21 @@ function expect_config_value()
|
||||
fi
|
||||
}
|
||||
|
||||
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
|
||||
check_response "osd_debug_op_order = 'false'"
|
||||
ceph tell osd.0 injectargs -- --osd_debug_op_order >& $TMPFILE || return 1
|
||||
check_response "osd_debug_op_order = 'true'"
|
||||
ceph tell osd.0 injectargs -- '--osd_debug_op_order --osd_debug_drop_ping_probability 555' >& $TMPFILE || return 1
|
||||
check_response "osd_debug_drop_ping_probability = '555' osd_debug_op_order = 'true'"
|
||||
}
|
||||
|
||||
function test_mon_injectargs_SI()
|
||||
{
|
||||
# Test SI units during injectargs and 'config set'
|
||||
@ -179,7 +194,10 @@ function test_mon_injectargs_SI()
|
||||
expect_config_value "mon.a" "mon_pg_warn_min_objects" 10240
|
||||
ceph tell mon.a injectargs '--mon_pg_warn_min_objects 1G'
|
||||
expect_config_value "mon.a" "mon_pg_warn_min_objects" 1073741824
|
||||
expect_false ceph injectargs mon.a '--mon_pg_warn_min_objects 10F'
|
||||
# < /dev/null accounts for the fact that ceph will go in interactive mode
|
||||
# because injectargs is discarded (actually saved for the benefit of
|
||||
# a tell command that never comes)
|
||||
expect_false ceph injectargs mon.a '--mon_pg_warn_min_objects 10F' < /dev/null 2> /dev/null
|
||||
$SUDO ceph daemon mon.a config set mon_pg_warn_min_objects $initial_value
|
||||
}
|
||||
|
||||
@ -1274,6 +1292,7 @@ function test_osd_bench()
|
||||
|
||||
set +x
|
||||
TESTS=(
|
||||
mon_injectargs
|
||||
mon_injectargs_SI
|
||||
tiering
|
||||
auth
|
||||
|
30
src/ceph.in
30
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:
|
||||
@ -537,6 +540,9 @@ def main():
|
||||
global verbose
|
||||
verbose = parsed_args.verbose
|
||||
|
||||
if verbose:
|
||||
print >> sys.stderr, "parsed_args: {0}, childargs: {1}".format(parsed_args, childargs)
|
||||
|
||||
if parsed_args.admin_socket_nope:
|
||||
print >> sys.stderr, '--admin-socket is used by daemons; '\
|
||||
'you probably mean --admin-daemon/daemon'
|
||||
@ -609,6 +615,16 @@ def main():
|
||||
'log_flush_on_exit':'true',
|
||||
}
|
||||
|
||||
if 'injectargs' in childargs:
|
||||
position = childargs.index('injectargs')
|
||||
injectargs = childargs[position:]
|
||||
childargs = childargs[:position]
|
||||
if verbose:
|
||||
print >> sys.stderr, 'Separate childargs {0} from injectargs {1}'.\
|
||||
format(childargs, injectargs)
|
||||
else:
|
||||
injectargs = None
|
||||
|
||||
clustername = 'ceph'
|
||||
if parsed_args.cluster:
|
||||
clustername = parsed_args.cluster
|
||||
@ -623,7 +639,6 @@ def main():
|
||||
format(repr(e))
|
||||
return 1
|
||||
|
||||
#tmp = childargs
|
||||
childargs = retargs
|
||||
if not childargs:
|
||||
childargs = []
|
||||
@ -742,10 +757,13 @@ def main():
|
||||
childargs = childargs[2:]
|
||||
is_tell = True
|
||||
|
||||
if is_tell and not len(childargs):
|
||||
print >> sys.stderr, \
|
||||
if is_tell:
|
||||
if injectargs:
|
||||
childargs = injectargs
|
||||
if not len(childargs):
|
||||
print >> sys.stderr, \
|
||||
'Cannot use \'tell\' with interactive mode'
|
||||
return errno.EINVAL
|
||||
return errno.EINVAL
|
||||
|
||||
# fetch JSON sigs from command
|
||||
# each line contains one command signature (a placeholder name
|
||||
|
@ -898,6 +898,9 @@ def validate_command(sigdict, args, verbose=False):
|
||||
turn args into a valid dictionary ready to be sent off as JSON,
|
||||
validated against sigdict.
|
||||
"""
|
||||
if verbose:
|
||||
print >> sys.stderr, \
|
||||
"validate_command: " + " ".join(args)
|
||||
found = []
|
||||
valid_dict = {}
|
||||
if args:
|
||||
|
Loading…
Reference in New Issue
Block a user