]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/nfs: Do not ignore clusters from rados pool conf objects 58284/head
authorAnoop C S <anoopcs@cryptolab.net>
Thu, 11 Jul 2024 07:46:30 +0000 (13:16 +0530)
committerPonnuvel Palaniyappan <pponnuvel@gmail.com>
Thu, 25 Jul 2024 17:10:11 +0000 (18:10 +0100)
Early handling of NoOrchestrator exception via a2192c73e41e prevented us
from looking for namespaces containing conf objects in .nfs pool. This
would mean that we fail to recognize such namespaces as clusters thereby
prohibiting the creation of nfs exports. We could instead search for
such namespaces while handling the NoOrchestrator exception within
available_clusters() before returning the final list of clusters.

Fixes: https://tracker.ceph.com/issues/66800
Signed-off-by: Anoop C S <anoopcs@cryptolab.net>
Conflicts:
src/pybind/mgr/nfs/export.py

src/pybind/mgr/nfs/export.py
src/pybind/mgr/nfs/utils.py

index 3fa263ed8239cb22d9e04c1c68fafbb8ab8175a8..b1dc5f739dade7966d31a853369a06d5095f35f2 100644 (file)
@@ -15,9 +15,8 @@ from typing import (
 from os.path import normpath
 import cephfs
 
-from rados import TimedOut, ObjectNotFound, Rados, LIBRADOS_ALL_NSPACES
+from rados import TimedOut, ObjectNotFound, Rados
 
-from orchestrator import NoOrchestrator
 from mgr_module import NFS_POOL_NAME as POOL_NAME, NFS_GANESHA_SUPPORTED_FSALS
 
 from .ganesha_conf import (
@@ -29,7 +28,6 @@ from .ganesha_conf import (
     format_block)
 from .exception import NFSException, NFSInvalidOperation, FSNotFound, NFSObjectNotFound
 from .utils import (
-    CONF_PREFIX,
     EXPORT_PREFIX,
     USER_CONF_PREFIX,
     export_obj_name,
@@ -48,11 +46,7 @@ log = logging.getLogger(__name__)
 
 def known_cluster_ids(mgr: 'Module') -> Set[str]:
     """Return the set of known cluster IDs."""
-    try:
-        clusters = set(available_clusters(mgr))
-    except NoOrchestrator:
-        clusters = nfs_rados_configs(mgr.rados)
-    return clusters
+    return set(available_clusters(mgr))
 
 
 def export_cluster_checker(func: FuncT) -> FuncT:
@@ -171,21 +165,6 @@ class NFSRados:
         return False
 
 
-def nfs_rados_configs(rados: 'Rados', nfs_pool: str = POOL_NAME) -> Set[str]:
-    """Return a set of all the namespaces in the nfs_pool where nfs
-    configuration objects are found. The namespaces also correspond
-    to the cluster ids.
-    """
-    ns: Set[str] = set()
-    prefixes = (EXPORT_PREFIX, CONF_PREFIX, USER_CONF_PREFIX)
-    with rados.open_ioctx(nfs_pool) as ioctx:
-        ioctx.set_namespace(LIBRADOS_ALL_NSPACES)
-        for obj in ioctx.list_objects():
-            if obj.key.startswith(prefixes):
-                ns.add(obj.nspace)
-    return ns
-
-
 class ExportMgr:
     def __init__(
             self,
index b90bb3c75d5c050a45290fa0d113d4028fd67f04..b57b899e8df2952b717b3f861a57f15ab48ad39e 100644 (file)
@@ -7,6 +7,9 @@ import orchestrator
 from orchestrator import NoOrchestrator
 import cephfs
 from mgr_util import CephfsClient, open_filesystem
+from mgr_module import NFS_POOL_NAME as POOL_NAME
+
+from rados import Rados, LIBRADOS_ALL_NSPACES, ObjectNotFound
 
 if TYPE_CHECKING:
     from nfs.module import Module
@@ -42,18 +45,36 @@ def available_clusters(mgr: 'Module') -> List[str]:
     <ServiceDescription of <NFSServiceSpec for service_name=nfs.vstart>>
     return value: ['vstart']
     '''
-    # TODO check cephadm cluster list with rados pool conf objects
     try:
         completion = mgr.describe_service(service_type='nfs')
     except NoOrchestrator:
-        log.exception("No orchestrator configured")
-        return []
+        log.debug("No orchestrator configured")
+        return nfs_rados_configs(mgr.rados)
     orchestrator.raise_if_exception(completion)
     assert completion.result is not None
     return [cluster.spec.service_id for cluster in completion.result
             if cluster.spec.service_id]
 
 
+def nfs_rados_configs(rados: 'Rados', nfs_pool: str = POOL_NAME) -> List[str]:
+    """Return a list of all the namespaces in the nfs_pool where nfs
+    configuration objects are found. The namespaces also correspond
+    to the cluster ids.
+    """
+    ns: List[str] = []
+    prefixes = (EXPORT_PREFIX, CONF_PREFIX, USER_CONF_PREFIX)
+    try:
+        with rados.open_ioctx(nfs_pool) as ioctx:
+            ioctx.set_namespace(LIBRADOS_ALL_NSPACES)
+            for obj in ioctx.list_objects():
+                if obj.key.startswith(prefixes):
+                    ns.append(obj.nspace)
+    except ObjectNotFound:
+        log.debug("Failed to open pool %s", nfs_pool)
+    finally:
+        return ns
+
+
 def restart_nfs_service(mgr: 'Module', cluster_id: str) -> None:
     '''
     This methods restarts the nfs daemons