From: John Mulligan Date: Thu, 2 May 2024 20:40:53 +0000 (-0400) Subject: mgr/smb: convert failures to create a valid resource into error results X-Git-Tag: v20.0.0~1709^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=31ffcda9e88e15b61cb1d3a4fdeb7cf356d918da;p=ceph.git mgr/smb: convert failures to create a valid resource into error results Convert failures to create a valid resource into error results that can be reported back to the caller like the other error result types generated by actually attempting to apply the resources. Signed-off-by: John Mulligan --- diff --git a/src/pybind/mgr/smb/module.py b/src/pybind/mgr/smb/module.py index 34bab3c82a0..d8133a59c47 100644 --- a/src/pybind/mgr/smb/module.py +++ b/src/pybind/mgr/smb/module.py @@ -63,7 +63,14 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule): """Create, update, or remove smb configuration resources based on YAML or JSON specs """ - return self._handler.apply(resources.load_text(inbuf)) + try: + return self._handler.apply(resources.load_text(inbuf)) + except resources.InvalidResourceError as err: + # convert the exception into a result and return it as the only + # item in the result group + return results.ResultGroup( + [results.InvalidResourceResult(err.resource_data, str(err))] + ) @cli.SMBCommand('cluster ls', perm='r') def cluster_ls(self) -> List[str]: