From: Sage Weil Date: Tue, 23 Feb 2021 21:51:09 +0000 (-0500) Subject: mgr/orchestrator: validate config options at apply time X-Git-Tag: v17.1.0~2814^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F39648%2Fhead;p=ceph.git mgr/orchestrator: validate config options at apply time Make sure config options are valid/exist. Signed-off-by: Sage Weil --- diff --git a/src/pybind/mgr/orchestrator/module.py b/src/pybind/mgr/orchestrator/module.py index ed1f75da50a3..85dd8749c049 100644 --- a/src/pybind/mgr/orchestrator/module.py +++ b/src/pybind/mgr/orchestrator/module.py @@ -10,7 +10,8 @@ from prettytable import PrettyTable from ceph.deployment.inventory import Device from ceph.deployment.drive_group import DriveGroupSpec, DeviceSelection -from ceph.deployment.service_spec import PlacementSpec, ServiceSpec +from ceph.deployment.service_spec import PlacementSpec, ServiceSpec, \ + ServiceSpecValidationError from ceph.utils import datetime_now from mgr_util import to_pretty_timedelta, format_dimless @@ -1062,6 +1063,15 @@ Usage: specs: List[Union[ServiceSpec, HostSpec]] = [] for s in content: spec = json_to_generic_spec(s) + + # validate the config (we need MgrModule for that) + if isinstance(spec, ServiceSpec) and spec.config: + for k, v in spec.config.items(): + try: + self.get_foreign_ceph_option('mon', k) + except KeyError: + raise ServiceSpecValidationError(f'Invalid config option {k} in spec') + if dry_run and not isinstance(spec, HostSpec): spec.preview_only = dry_run specs.append(spec)