From 31ffcda9e88e15b61cb1d3a4fdeb7cf356d918da Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Thu, 2 May 2024 16:40:53 -0400 Subject: [PATCH] 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 --- src/pybind/mgr/smb/module.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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]: -- 2.39.5