summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSage Weil <sage@inktank.com>2013-08-09 15:14:56 -0700
committerSage Weil <sage@inktank.com>2013-08-09 15:38:39 -0700
commit44b093c80844dbed6a60216eb1ff17e02c505395 (patch)
tree4768ce1d982bb5f8e903ef54dae5ff73feaab590
parent7ed6de9dd7aed59f3c5dd93e012cf080bcc36d8a (diff)
downloadceph-44b093c80844dbed6a60216eb1ff17e02c505395.tar.gz
ceph: retry new-style mon command if we get EINVAL from the old-style command
We can race with a mon upgrade: - get command descriptions, get EINVAL - mons upgrade, new quorum - send old-style command - get EINVAL In this case, we should try one last time to get the command descriptions. Fixes: #5788 Reviewed-by: Dan Mick <dan.mick@inktank.com> Signed-off-by: Sage Weil <sage@inktank.com>
-rwxr-xr-xsrc/ceph.in38
1 files changed, 23 insertions, 15 deletions
diff --git a/src/ceph.in b/src/ceph.in
index 38150ed07d7..fa79a720656 100755
--- a/src/ceph.in
+++ b/src/ceph.in
@@ -691,26 +691,34 @@ def main():
childargs.extend(['--format', parsed_args.output_format])
ret, outbuf, outs = send_command(cluster_handle, target, childargs,
inbuf)
- elif ret:
- if ret < 0:
- outs = 'problem getting command descriptions from {0}.{1}'.format(*target)
- else:
- sigdict = parse_json_funcsigs(outbuf, 'cli')
- if parsed_args.completion:
- return complete(sigdict, childargs, target)
+ if ret == -errno.EINVAL:
+ # did we race with a mon upgrade? try again!
+ ret, outbuf, outs = json_command(cluster_handle, target=target,
+ prefix='get_command_descriptions')
+ if ret == 0:
+ compat = False # yep, carry on
+ if not compat:
+ if ret:
+ if ret < 0:
+ outs = 'problem getting command descriptions from {0}.{1}'.format(*target)
+ else:
+ sigdict = parse_json_funcsigs(outbuf, 'cli')
- ret, outbuf, outs = new_style_command(parsed_args, childargs, target,
- sigdict, inbuf, verbose)
+ if parsed_args.completion:
+ return complete(sigdict, childargs, target)
- # debug tool: send any successful command *again* to
- # verify that it is idempotent.
- if not ret and 'CEPH_CLI_TEST_DUP_COMMAND' in os.environ:
ret, outbuf, outs = new_style_command(parsed_args, childargs, target,
sigdict, inbuf, verbose)
- if ret < 0:
- ret = -ret
- print >> sys.stderr, prefix + 'Second attempt of previously successful command failed with {0}: {1}'.format(errno.errorcode[ret], outs)
+
+ # debug tool: send any successful command *again* to
+ # verify that it is idempotent.
+ if not ret and 'CEPH_CLI_TEST_DUP_COMMAND' in os.environ:
+ ret, outbuf, outs = new_style_command(parsed_args, childargs, target,
+ sigdict, inbuf, verbose)
+ if ret < 0:
+ ret = -ret
+ print >> sys.stderr, prefix + 'Second attempt of previously successful command failed with {0}: {1}'.format(errno.errorcode[ret], outs)
if ret < 0:
ret = -ret