From: John Mulligan Date: Fri, 11 Oct 2024 18:58:40 +0000 (-0400) Subject: mgr/smb: prevent switching between clustering modes X-Git-Tag: v20.0.0~725^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F60281%2Fhead;p=ceph.git mgr/smb: prevent switching between clustering modes Prevent users from changing the cluster resource values such that a cluster is changed from not using CTDB to using CTDB and vice versa. This avoids complex situations that arise when making these sorts of changes, in particular going from CTDB to non-CTDB which I am very sure will mess up the tdb files. Blocking these changes limits the need to test changing clustering behavior on the fly. We can always revisit this in the future if needed. Fixes: https://tracker.ceph.com/issues/68511 Signed-off-by: John Mulligan --- diff --git a/src/pybind/mgr/smb/handler.py b/src/pybind/mgr/smb/handler.py index 9a62722d255..5adf319b2f5 100644 --- a/src/pybind/mgr/smb/handler.py +++ b/src/pybind/mgr/smb/handler.py @@ -29,6 +29,7 @@ from .enums import ( JoinSourceType, LoginAccess, LoginCategory, + SMBClustering, State, UserGroupSourceType, ) @@ -869,6 +870,25 @@ def _check_cluster_modifications( 'domain/realm value may not be changed', status={'existing_domain_realm': prev.domain_settings.realm}, ) + if cluster.is_clustered() != prev.is_clustered(): + prev_clustering = prev.is_clustered() + cterms = {True: 'enabled', False: 'disabled'} + msg = ( + f'a cluster resource with clustering {cterms[prev_clustering]}' + f' may not be changed to clustering {cterms[not prev_clustering]}' + ) + opt_terms = { + True: SMBClustering.ALWAYS.value, + False: SMBClustering.NEVER.value, + } + hint = { + 'note': ( + 'Set "clustering" to an explicit value that matches the' + ' current clustering behavior' + ), + 'value': opt_terms[prev_clustering], + } + raise ErrorResult(cluster, msg, status={'hint': hint}) def _parse_earmark(earmark: str) -> dict: