]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: add ok_to_stop func for smb service 60300/head
authorAvan Thakkar <athakkar@redhat.com>
Mon, 14 Oct 2024 14:02:11 +0000 (19:32 +0530)
committerAvan Thakkar <athakkar@redhat.com>
Mon, 14 Oct 2024 18:30:09 +0000 (00:00 +0530)
Fixes: https://tracker.ceph.com/issues/68527
Signed-off-by: Avan Thakkar <athakkar@redhat.com>
src/pybind/mgr/cephadm/services/smb.py

index dabc202a024bd3a19dbaf4d0891d79af5f399e81..e322acb0e3e7383c81effcd40e9982e73f238389 100644 (file)
@@ -1,6 +1,9 @@
+import errno
 import logging
 from typing import Any, Dict, List, Tuple, cast, Optional
 
+from mgr_module import HandleCommandResult
+
 from ceph.deployment.service_spec import ServiceSpec, SMBSpec
 
 from orchestrator import DaemonDescription
@@ -117,6 +120,23 @@ class SMBService(CephService):
             return True
         return False
 
+    def ok_to_stop(
+        self, daemon_ids: List[str], force: bool = False, known: Optional[List[str]] = None
+    ) -> HandleCommandResult:
+        # if only 1 smb, alert user (this is not passable with --force)
+        warn, warn_message = self._enough_daemons_to_stop(self.TYPE, daemon_ids, "SMB", 1, True)
+        if warn:
+            return HandleCommandResult(-errno.EBUSY, "", warn_message)
+
+        # if reached here, there is > 1 smb daemon.
+        if force:
+            return HandleCommandResult(0, warn_message, "")
+
+        # if reached here, > 1 smb daemon and no force flag.
+        # Provide warning
+        warn_message = "WARNING: Removing SMB daemons can cause clients to lose connectivity. "
+        return HandleCommandResult(-errno.EBUSY, "", warn_message)
+
     def _allow_config_key_command(self, name: str) -> str:
         # permit the samba container config access to the mon config key store
         # with keys like smb/config/<cluster_id>/*.