Skip to content

Commit 31ffcda

Browse files
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 <[email protected]>
1 parent 014bd30 commit 31ffcda

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/pybind/mgr/smb/module.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,14 @@ def apply_resources(self, inbuf: str) -> results.ResultGroup:
6363
"""Create, update, or remove smb configuration resources based on YAML
6464
or JSON specs
6565
"""
66-
return self._handler.apply(resources.load_text(inbuf))
66+
try:
67+
return self._handler.apply(resources.load_text(inbuf))
68+
except resources.InvalidResourceError as err:
69+
# convert the exception into a result and return it as the only
70+
# item in the result group
71+
return results.ResultGroup(
72+
[results.InvalidResourceResult(err.resource_data, str(err))]
73+
)
6774

6875
@cli.SMBCommand('cluster ls', perm='r')
6976
def cluster_ls(self) -> List[str]:

0 commit comments

Comments
 (0)