]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/smb: prevent switching between clustering modes
authorJohn Mulligan <jmulligan@redhat.com>
Fri, 11 Oct 2024 18:58:40 +0000 (14:58 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Sat, 12 Oct 2024 17:37:51 +0000 (13:37 -0400)
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 <jmulligan@redhat.com>
src/pybind/mgr/smb/handler.py

index 9a62722d255ec547a6233e313867ede9f430ba1c..5adf319b2f527fbd4c34af520450aa28e82e9ba5 100644 (file)
@@ -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: