Skip to content

Commit

Permalink
Merge pull request ceph#44870 from phlogistonjohn/jjm-nfs-cleanups2
Browse files Browse the repository at this point in the history
mgr/nfs: support managing exports without orchestration enabled 

Reviewed-by: Ramana Raja <rraja@redhat.com>
  • Loading branch information
adk3798 committed Feb 25, 2022
2 parents b39f36b + b5b3e0b commit 9222118
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 10 deletions.
20 changes: 13 additions & 7 deletions doc/mgr/nfs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -533,20 +533,26 @@ The NFS log level can be adjusted using `nfs cluster config set` command (see :r
Manual Ganesha deployment
=========================

It may be possible to deploy and manage the NFS ganesha daemons manually
instead of allowing cephadm or rook to do so.
It may be possible to deploy and manage the NFS ganesha daemons without
orchestration frameworks such as cephadm or rook.

.. note:: Manual configuration is not tested or fully documented; your
mileage may vary. If you make this work, please help us by
updating this documentation.

Known issues
Limitations
------------

* The ``mgr/nfs`` module enumerates NFS clusters via the orchestrator API; if NFS is
not managed by the orchestrator (e.g., cephadm or rook) then this will not work. It
may be possible to create the cluster, mark the cephadm service as 'unmanaged', but this
is awkward and not ideal.
If no orchestrator module is enabled for the Ceph Manager the NFS cluster
management commands, such as those starting with ``ceph nfs cluster``, will not
function. However, commands that manage NFS exports, like those prefixed with
``ceph nfs export`` are expected to work as long as the necessary RADOS objects
have already been created. The exact RADOS objects required are not documented
at this time as support for this feature is incomplete. A curious reader can
find some details about the object by reading the source code for the
``mgr/nfs`` module (found in the ceph source tree under
``src/pybind/mgr/nfs``).


Requirements
------------
Expand Down
40 changes: 37 additions & 3 deletions src/pybind/mgr/nfs/export.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
import errno
import json
import logging
from typing import List, Any, Dict, Tuple, Optional, TYPE_CHECKING, TypeVar, Callable, cast
from typing import (
List,
Any,
Dict,
Tuple,
Optional,
TYPE_CHECKING,
TypeVar,
Callable,
Set,
cast)
from os.path import normpath

from rados import TimedOut, ObjectNotFound, Rados
from rados import TimedOut, ObjectNotFound, Rados, LIBRADOS_ALL_NSPACES

from orchestrator import NoOrchestrator
from mgr_module import NFS_POOL_NAME as POOL_NAME, NFS_GANESHA_SUPPORTED_FSALS

from .export_utils import GaneshaConfParser, Export, RawBlock, CephFSFSAL, RGWFSAL
from .exception import NFSException, NFSInvalidOperation, FSNotFound, \
ClusterNotFound
from .utils import (
CONF_PREFIX,
EXPORT_PREFIX,
USER_CONF_PREFIX,
export_obj_name,
Expand All @@ -37,7 +49,14 @@ def cluster_check(
"""
This method checks if cluster exists
"""
if kwargs['cluster_id'] not in available_clusters(export.mgr):
try:
clusters = set(available_clusters(export.mgr))
except NoOrchestrator:
clusters = nfs_rados_configs(export.mgr.rados)
cluster_id: str = kwargs['cluster_id']
log.debug("checking for %r in known nfs clusters: %r",
cluster_id, clusters)
if cluster_id not in clusters:
return -errno.ENOENT, "", "Cluster does not exist"
return func(export, *args, **kwargs)
return cast(FuncT, cluster_check)
Expand Down Expand Up @@ -138,6 +157,21 @@ def check_user_config(self) -> bool:
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,
Expand Down

0 comments on commit 9222118

Please sign in to comment.