Skip to content

Commit 8d2d54f

Browse files
author
neeraj pratap singh
committed
cephfs-shell: fixing the cephfs-shell test failures
cephfs-shell is failing in Ubuntu22.04, because it is behaving weirdly with cmd2's version. It is taking cmd2 version as 0.0.0 instead of the correct version. Fixes: https://tracker.ceph.com/issues/63700 Signed-off-by: Neeraj Pratap Singh <[email protected]>
1 parent 2ab1415 commit 8d2d54f

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/tools/cephfs/shell/cephfs-shell

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,22 @@ import re
1515
import shlex
1616
import stat
1717
import errno
18+
import distro
1819

1920
from cmd2 import Cmd
2021
from cmd2 import __version__ as cmd2_version
2122
from packaging.version import Version
2223

24+
# DFLAG is used to override the checks done by cephfs-shell
25+
# for cmd2 versions due to weird behaviour of Ubuntu22.04 with
26+
# cmd2's version i.e. it always gets the version of cmd2 as
27+
# "0.0.0" instead of the actual cmd2 version.
28+
DFLAG = False
29+
if distro.name() == "Ubuntu" and distro.version() == "22.04":
30+
DFLAG = True
2331
# XXX: In cmd2 versions < 1.0.1, we'll get SystemExit(2) instead of
2432
# Cmd2ArgparseError
25-
if Version(cmd2_version) >= Version("1.0.1"):
33+
if Version(cmd2_version) >= Version("1.0.1") or DFLAG is True:
2634
from cmd2.exceptions import Cmd2ArgparseError
2735
else:
2836
# HACK: so that we don't have check for version everywhere
@@ -1700,7 +1708,7 @@ def read_shell_conf(shell, shell_conf_file):
17001708

17011709
sec = 'cephfs-shell'
17021710
opts = []
1703-
if Version(cmd2_version) >= Version("0.10.0"):
1711+
if Version(cmd2_version) >= Version("0.10.0") or DFLAG is True:
17041712
for attr in shell.settables.keys():
17051713
opts.append(attr)
17061714
else:
@@ -1768,7 +1776,7 @@ def manage_args():
17681776
args.exe_and_quit = False # Execute and quit, don't launch the shell.
17691777

17701778
if args.batch:
1771-
if Version(cmd2_version) <= Version("0.9.13"):
1779+
if Version(cmd2_version) <= Version("0.9.13") and DFLAG is not True:
17721780
args.commands = ['load ' + args.batch, ',quit']
17731781
else:
17741782
args.commands = ['run_script ' + args.batch, ',quit']
@@ -1813,7 +1821,7 @@ def execute_cmds_and_quit(args):
18131821
# value to indicate whether the execution of the commands should stop, but
18141822
# since 0.9.7 it returns the return value of do_* methods only if it's
18151823
# not None. When it is None it returns False instead of None.
1816-
if Version(cmd2_version) <= Version("0.9.6"):
1824+
if Version(cmd2_version) <= Version("0.9.6") and DFLAG is not True:
18171825
stop_exec_val = None
18181826
else:
18191827
stop_exec_val = False

0 commit comments

Comments
 (0)