Skip to content

Commit da89acd

Browse files
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 <[email protected]>
1 parent 263c0f8 commit da89acd

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/pybind/mgr/smb/handler.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
JoinSourceType,
3030
LoginAccess,
3131
LoginCategory,
32+
SMBClustering,
3233
State,
3334
UserGroupSourceType,
3435
)
@@ -869,6 +870,25 @@ def _check_cluster_modifications(
869870
'domain/realm value may not be changed',
870871
status={'existing_domain_realm': prev.domain_settings.realm},
871872
)
873+
if cluster.is_clustered() != prev.is_clustered():
874+
prev_clustering = prev.is_clustered()
875+
cterms = {True: 'enabled', False: 'disabled'}
876+
msg = (
877+
f'a cluster resource with clustering {cterms[prev_clustering]}'
878+
f' may not be changed to clustering {cterms[not prev_clustering]}'
879+
)
880+
opt_terms = {
881+
True: SMBClustering.ALWAYS.value,
882+
False: SMBClustering.NEVER.value,
883+
}
884+
hint = {
885+
'note': (
886+
'Set "clustering" to an explicit value that matches the'
887+
' current clustering behavior'
888+
),
889+
'value': opt_terms[prev_clustering],
890+
}
891+
raise ErrorResult(cluster, msg, status={'hint': hint})
872892

873893

874894
def _parse_earmark(earmark: str) -> dict:

0 commit comments

Comments
 (0)