]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: mgr orchestrator module raise exception if there is trailing tab in... 61035/head
authorShweta Bhosale <Shweta.Bhosale1@ibm.com>
Wed, 11 Dec 2024 07:37:15 +0000 (13:07 +0530)
committerShweta Bhosale <Shweta.Bhosale1@ibm.com>
Tue, 7 Jan 2025 05:30:06 +0000 (11:00 +0530)
Fixes: https://tracker.ceph.com/issues/69192
Signed-off-by: Shweta Bhosale <Shweta.Bhosale1@ibm.com>
src/pybind/mgr/orchestrator/module.py

index 332bc75d862e7c11ebbaff6fb709519b0e70efa0..c31dd761a196ada848742d31d343a5c65fa28165 100644 (file)
@@ -1666,7 +1666,13 @@ Usage:
             specs: List[Union[ServiceSpec, HostSpec]] = []
             # YAML '---' document separator with no content generates
             # None entries in the output. Let's skip them silently.
-            content = [o for o in yaml_objs if o is not None]
+            try:
+                content = [o for o in yaml_objs if o is not None]
+            except yaml.scanner.ScannerError as e:
+                msg = f"Invalid YAML received : {str(e)}"
+                self.log.exception(msg)
+                return HandleCommandResult(-errno.EINVAL, stderr=msg)
+
             for s in content:
                 try:
                     spec = json_to_generic_spec(s)
@@ -2191,7 +2197,13 @@ Usage:
             specs: List[TunedProfileSpec] = []
             # YAML '---' document separator with no content generates
             # None entries in the output. Let's skip them silently.
-            content = [o for o in yaml_objs if o is not None]
+            try:
+                content = [o for o in yaml_objs if o is not None]
+            except yaml.scanner.ScannerError as e:
+                msg = f"Invalid YAML received : {str(e)}"
+                self.log.exception(msg)
+                return HandleCommandResult(-errno.EINVAL, stderr=msg)
+
             for spec in content:
                 specs.append(TunedProfileSpec.from_json(spec))
         else: