]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
src: fixing assert_valid_host 60156/head
authorNeeraj Pratap Singh <Neeraj.Pratap.Singh1@ibm.com>
Wed, 21 Jan 2026 09:50:55 +0000 (15:20 +0530)
committerNeeraj Pratap Singh <Neeraj.Pratap.Singh1@ibm.com>
Tue, 24 Mar 2026 03:49:37 +0000 (09:19 +0530)
Removed the stacktrace from command output in case of error
Fixes: https://tracker.ceph.com/issues/68420
Signed-off-by: Neeraj Pratap Singh <neesingh@redhat.com>
src/pybind/mgr/volumes/fs/fs_util.py
src/python-common/ceph/deployment/hostspec.py

index e37bfe29d06b7e2c650b629b20b7439936c1381e..b656b4c9020e46eb5e9f10183bcc3d08d40c694f 100644 (file)
@@ -47,9 +47,12 @@ def rename_filesystem(mgr, fs_name, new_fs_name):
     return mgr.mon_command(command)
 
 def create_mds(mgr, fs_name, placement):
-    spec = ServiceSpec(service_type='mds',
-                                    service_id=fs_name,
-                                    placement=PlacementSpec.from_string(placement))
+    try:
+        spec = ServiceSpec(service_type='mds',
+                           service_id=fs_name,
+                           placement=PlacementSpec.from_string(placement))
+    except Exception as e:
+        return -errno.EINVAL, "", str(e)
     try:
         completion = mgr.apply([spec], no_overwrite=True)
         orchestrator.raise_if_exception(completion)
index f17ba81cf09bef885a308635c9261e447334b3f1..c73c818bfacb5b44ee31b2ff1b1bd21033abcff9 100644 (file)
@@ -6,14 +6,18 @@ from typing import Optional, List, Any, Dict
 
 def assert_valid_host(name: str) -> None:
     p = re.compile('^[a-zA-Z0-9-]+$')
-    try:
-        assert len(name) <= 250, 'name is too long (max 250 chars)'
-        for part in name.split('.'):
-            assert len(part) > 0, '.-delimited name component must not be empty'
-            assert len(part) <= 63, '.-delimited name component must not be more than 63 chars'
-            assert p.match(part), 'name component must include only a-z, 0-9, and -'
-    except AssertionError as e:
-        raise SpecValidationError(str(e) + f'. Got "{name}"')
+    if len(name) > 250:
+        raise AssertionError(f'{name}: name is too long (max 250 chars)') from None
+    for part in name.split('.'):
+        if len(part) == 0:
+            raise AssertionError('.-delimited name component must not be empty '
+                                 f'but got {name}') from None
+        if len(part) > 63:
+            raise AssertionError('.-delimited name component must not be more '
+                                 f'than 63 chars but got {name}') from None
+        if not p.match(part):
+            raise AssertionError('name component must include only a-z, 0-9, '
+                                 f'and - but got {name}') from None
 
 
 def assert_valid_oob(oob: Dict[str, str]) -> None: