summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShweta Bhosale <Shweta.Bhosale1@ibm.com>2024-12-11 08:37:15 +0100
committerShweta Bhosale <Shweta.Bhosale1@ibm.com>2025-01-07 06:30:06 +0100
commitdfa632b42558278d26cabb88248aa7ae8ba8fcfc (patch)
tree37879e7eef312fb3ddf18887615da3792821b277
parentMerge pull request #60928 from adk3798/fix-nvme-loop-parsing (diff)
downloadceph-dfa632b42558278d26cabb88248aa7ae8ba8fcfc.tar.xz
ceph-dfa632b42558278d26cabb88248aa7ae8ba8fcfc.zip
mgr/cephadm: mgr orchestrator module raise exception if there is trailing tab in yaml file
Fixes: https://tracker.ceph.com/issues/69192 Signed-off-by: Shweta Bhosale <Shweta.Bhosale1@ibm.com>
-rw-r--r--src/pybind/mgr/orchestrator/module.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/pybind/mgr/orchestrator/module.py b/src/pybind/mgr/orchestrator/module.py
index 332bc75d862..c31dd761a19 100644
--- a/src/pybind/mgr/orchestrator/module.py
+++ b/src/pybind/mgr/orchestrator/module.py
@@ -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: