Skip to content

Commit df7b755

Browse files
committed
Merge PR ceph#63281 into main
* refs/pull/63281/head: Revert "mgr/volumes: handle bad arguments during subvolume create" Reviewed-by: Rishabh Dave <[email protected]>
2 parents 9e1f412 + ddb86b7 commit df7b755

File tree

6 files changed

+6
-61
lines changed

6 files changed

+6
-61
lines changed

doc/_ext/ceph_commands.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class CmdParam(object):
8383

8484
def __init__(self, type, name,
8585
who=None, n=None, req=True, range=None, strings=None,
86-
goodchars=None, positional=True, **kwargs):
86+
goodchars=None, positional=True):
8787
self.type = type
8888
self.name = name
8989
self.who = who
@@ -93,7 +93,6 @@ def __init__(self, type, name,
9393
self.strings = strings.split('|') if strings else []
9494
self.goodchars = goodchars
9595
self.positional = positional != 'false'
96-
self.allowempty = kwargs.pop('allowempty', True) in (True, 'True', 'true')
9796

9897
assert who is None
9998

@@ -109,8 +108,6 @@ def help(self):
109108
advanced.append('goodchars= ``{}`` '.format(self.goodchars))
110109
if self.n:
111110
advanced.append('(can be repeated)')
112-
if self.allowempty:
113-
advanced.append('(can be empty string)')
114111

115112
advanced = advanced or ["(string)"]
116113
return ' '.join(advanced)

qa/suites/fs/volumes/tasks/volumes/test/basic.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,4 @@ tasks:
66
- tasks.cephfs.test_volumes.TestVolumeCreate
77
- tasks.cephfs.test_volumes.TestSubvolumeGroups
88
- tasks.cephfs.test_volumes.TestSubvolumes
9-
- tasks.cephfs.test_volumes.TestEmptyStringForCreates
109
- tasks.cephfs.test_subvolume

qa/tasks/cephfs/filesystem.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,7 @@ def create(self, **kwargs):
834834
assert(subvols['create'] > 0)
835835

836836
self.run_ceph_cmd('fs', 'subvolumegroup', 'create', self.name, 'qa')
837-
subvol_options = self.fs_config.get('subvol_options', None)
837+
subvol_options = self.fs_config.get('subvol_options', '')
838838

839839
for sv in range(0, subvols['create']):
840840
sv_name = f'sv_{sv}'

qa/tasks/cephfs/test_volumes.py

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -9260,48 +9260,3 @@ def test_volumes_module_finisher_thread(self):
92609260

92619261
# verify trash dir is clean
92629262
self._wait_for_trash_empty()
9263-
9264-
class TestEmptyStringForCreates(CephFSTestCase):
9265-
CLIENTS_REQUIRED = 1
9266-
MDSS_REQUIRED = 1
9267-
9268-
def setUp(self):
9269-
super().setUp()
9270-
result = json.loads(self.get_ceph_cmd_stdout("fs", "volume", "ls"))
9271-
self.assertTrue(len(result) > 0)
9272-
self.volname = result[0]['name']
9273-
9274-
def tearDown(self):
9275-
# clean up
9276-
super().tearDown()
9277-
9278-
def test_empty_name_string_for_subvolumegroup_name(self):
9279-
"""
9280-
To test that an empty string is unacceptable for a subvolumegroup name
9281-
"""
9282-
with self.assertRaises(CommandFailedError):
9283-
self.run_ceph_cmd("fs", "subvolumegroup", "create", self.volname, "")
9284-
9285-
with self.assertRaises(CommandFailedError):
9286-
self.run_ceph_cmd("fs", "subvolumegroup", "create", self.volname, "''")
9287-
9288-
def test_empty_name_string_for_subvolume_name(self):
9289-
"""
9290-
To test that an empty string is unacceptable for a subvolume name
9291-
"""
9292-
with self.assertRaises(CommandFailedError):
9293-
self.run_ceph_cmd("fs", "subvolume", "create", "")
9294-
9295-
with self.assertRaises(CommandFailedError):
9296-
self.run_ceph_cmd("fs", "subvolume", "create", "''")
9297-
9298-
def test_empty_name_string_for_subvolumegroup_name_argument(self):
9299-
"""
9300-
To test that an empty string is unacceptable for a subvolumegroup name
9301-
argument when creating a subvolume
9302-
"""
9303-
with self.assertRaises(CommandFailedError):
9304-
self.run_ceph_cmd("fs", "subvolume", "create", self.volname, "sv1", "--group_name")
9305-
9306-
with self.assertRaises(CommandFailedError):
9307-
self.run_ceph_cmd("fs", "subvolume", "create", self.volname, "sv1", "--group_name", "''")

src/pybind/ceph_argparse.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ class CephString(CephArgtype):
327327
"""
328328
String; pretty generic. goodchars is a RE char class of valid chars
329329
"""
330-
def __init__(self, goodchars='', allowempty=True):
330+
def __init__(self, goodchars=''):
331331
from string import printable
332332
try:
333333
re.compile(goodchars)
@@ -338,12 +338,8 @@ def __init__(self, goodchars='', allowempty=True):
338338
self.goodset = frozenset(
339339
[c for c in printable if re.match(goodchars, c)]
340340
)
341-
self.allowempty = allowempty in (True, 'True', 'true')
342341

343342
def valid(self, s: str, partial: bool = False) -> None:
344-
if not self.allowempty and s == "":
345-
raise ArgumentFormat("argument can't be an empty string")
346-
347343
sset = set(s)
348344
if self.goodset and not sset <= self.goodset:
349345
raise ArgumentFormat("invalid chars {0} in {1}".
@@ -354,7 +350,6 @@ def __str__(self) -> str:
354350
b = ''
355351
if self.goodchars:
356352
b += '(goodchars {0})'.format(self.goodchars)
357-
b += f'(allowempty {self.allowempty})'
358353
return '<string{0}>'.format(b)
359354

360355
def complete(self, s) -> List[str]:
@@ -366,7 +361,6 @@ def complete(self, s) -> List[str]:
366361
def argdesc(self, attrs):
367362
if self.goodchars:
368363
attrs['goodchars'] = self.goodchars
369-
attrs['allowempty'] = repr(self.allowempty)
370364
return super().argdesc(attrs)
371365

372366

src/pybind/mgr/volumes/module.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule):
8686
{
8787
'cmd': 'fs subvolumegroup create '
8888
'name=vol_name,type=CephString '
89-
f'name=group_name,type=CephString,goodchars={goodchars},allowempty=false '
89+
f'name=group_name,type=CephString,goodchars={goodchars} '
9090
'name=size,type=CephInt,req=false '
9191
'name=pool_layout,type=CephString,req=false '
9292
'name=uid,type=CephInt,req=false '
@@ -136,9 +136,9 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule):
136136
{
137137
'cmd': 'fs subvolume create '
138138
'name=vol_name,type=CephString '
139-
f'name=sub_name,type=CephString,goodchars={goodchars},allowempty=false '
139+
f'name=sub_name,type=CephString,goodchars={goodchars} '
140140
'name=size,type=CephInt,req=false '
141-
f'name=group_name,type=CephString,req=false,goodchars={goodchars},allowempty=false '
141+
'name=group_name,type=CephString,req=false '
142142
'name=pool_layout,type=CephString,req=false '
143143
'name=uid,type=CephInt,req=false '
144144
'name=gid,type=CephInt,req=false '

0 commit comments

Comments
 (0)