From da89acdc850743db272d6dff5c73d2c9874f7076 Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Fri, 11 Oct 2024 14:58:40 -0400 Subject: [PATCH] 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 --- src/pybind/mgr/smb/handler.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) 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: -- 2.39.5