From 1dfd8a0c365681cb881769e64a397604437358f9 Mon Sep 17 00:00:00 2001 From: Joseph Sawaya Date: Fri, 30 Jul 2021 12:07:31 -0400 Subject: [PATCH] mgr/rook, mgr/nfs: update rook orchestrator to create and use .nfs pool This commit moves the functionality for creating the .nfs pool from the nfs module to the rook module and makes the rook module use the .nfs pool when creating an NFS daemon. Signed-off-by: Joseph Sawaya --- src/pybind/mgr/rook/module.py | 5 ++++- src/pybind/mgr/rook/rook_cluster.py | 18 ++++++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/pybind/mgr/rook/module.py b/src/pybind/mgr/rook/module.py index 86ecef06382a8..fb9b8355cef97 100644 --- a/src/pybind/mgr/rook/module.py +++ b/src/pybind/mgr/rook/module.py @@ -512,6 +512,9 @@ class RookOrchestrator(MgrModule, orchestrator.Orchestrator): del self._drive_group_map[service_id] self._save_drive_groups() return f'Removed {service_name}' + elif service_type == 'ingress': + self.log.info("{0} service '{1}' does not exist".format('ingress', service_id)) + return 'The Rook orchestrator does not currently support ingress' else: raise orchestrator.OrchestratorError(f'Service type {service_type} not supported') @@ -553,7 +556,7 @@ class RookOrchestrator(MgrModule, orchestrator.Orchestrator): @handle_orch_error def apply_nfs(self, spec): # type: (NFSServiceSpec) -> str - return self.rook_cluster.apply_nfsgw(spec) + return self.rook_cluster.apply_nfsgw(spec, self) @handle_orch_error def remove_daemons(self, names: List[str]) -> List[str]: diff --git a/src/pybind/mgr/rook/rook_cluster.py b/src/pybind/mgr/rook/rook_cluster.py index bc29b30986830..3c622d446ee52 100644 --- a/src/pybind/mgr/rook/rook_cluster.py +++ b/src/pybind/mgr/rook/rook_cluster.py @@ -26,6 +26,9 @@ from ceph.deployment.drive_group import DriveGroupSpec from ceph.deployment.service_spec import ServiceSpec, NFSServiceSpec, RGWSpec, PlacementSpec, HostPlacementSpec from ceph.utils import datetime_now from ceph.deployment.drive_selection.matchers import SizeMatcher +from nfs.cluster import create_ganesha_pool +from nfs.module import Module +from nfs.export import NFSRados from mgr_module import NFS_POOL_NAME from mgr_util import merge_dicts @@ -49,7 +52,7 @@ from .rook_client._helper import CrdClass import orchestrator try: - from rook.module import RookEnv + from rook.module import RookEnv, RookOrchestrator except ImportError: pass # just used for type checking. @@ -1027,12 +1030,15 @@ class RookCluster(object): cos.CephObjectStore, 'cephobjectstores', name, _update_zone, _create_zone) - def apply_nfsgw(self, spec: NFSServiceSpec) -> str: + def apply_nfsgw(self, spec: NFSServiceSpec, mgr: 'RookOrchestrator') -> str: # TODO use spec.placement # TODO warn if spec.extended has entries we don't kow how # to action. # TODO Number of pods should be based on the list of hosts in the # PlacementSpec. + assert spec.service_id, "service id in NFS service spec cannot be an empty string or None " # for mypy typing + service_id = spec.service_id + mgr_module = cast(Module, mgr) count = spec.placement.count or 1 def _update_nfs(new: cnfs.CephNFS) -> cnfs.CephNFS: new.spec.server.active = count @@ -1047,7 +1053,7 @@ class RookCluster(object): ), spec=cnfs.Spec( rados=cnfs.Rados( - namespace=self.rook_env.namespace, + namespace=service_id, pool=NFS_POOL_NAME, ), server=cnfs.Server( @@ -1056,12 +1062,12 @@ class RookCluster(object): ) ) - rook_nfsgw.spec.rados.namespace = cast(str, spec.service_id) return rook_nfsgw - assert spec.service_id is not None - return self._create_or_patch(cnfs.CephNFS, 'cephnfses', spec.service_id, + create_ganesha_pool(mgr) + NFSRados(mgr_module, service_id).write_obj('', f'conf-nfs.{spec.service_id}') + return self._create_or_patch(cnfs.CephNFS, 'cephnfses', service_id, _update_nfs, _create_nfs) def rm_service(self, rooktype: str, service_id: str) -> str: -- 2.39.5