From 82e939d89c3b6e2ce6faad9a5315c5372fef341d Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 2 Jul 2021 12:39:29 -0400 Subject: [PATCH] mgr/nfs: change nfs pool to .nfs This is a new pool that we can migrate all past NFS configuration to, simplifying the migration process (and also allowing us to pick a .-prefixed name). Signed-off-by: Sage Weil --- qa/tasks/cephfs/test_nfs.py | 8 +++---- src/pybind/mgr/cephadm/services/nfs.py | 4 +--- src/pybind/mgr/mgr_module.py | 2 ++ src/pybind/mgr/nfs/cluster.py | 3 ++- src/pybind/mgr/nfs/export.py | 4 +++- src/pybind/mgr/nfs/tests/test_nfs.py | 22 +++++++++---------- src/pybind/mgr/nfs/utils.py | 2 -- src/pybind/mgr/rook/rook_cluster.py | 7 ++---- .../ceph/deployment/service_spec.py | 2 +- 9 files changed, 25 insertions(+), 29 deletions(-) diff --git a/qa/tasks/cephfs/test_nfs.py b/qa/tasks/cephfs/test_nfs.py index 3013dffe1e540..dae3e9f9d6cff 100644 --- a/qa/tasks/cephfs/test_nfs.py +++ b/qa/tasks/cephfs/test_nfs.py @@ -161,7 +161,7 @@ class TestNFS(MgrTestCase): self._cmd(*export_cmd) # Check if user id for export is created self._check_auth_ls(export_id, check_in=True) - res = self._sys_cmd(['rados', '-p', 'nfs-ganesha', '-N', self.cluster_id, 'get', + res = self._sys_cmd(['rados', '-p', '.nfs', '-N', self.cluster_id, 'get', f'export-{export_id}', '-']) # Check if export object is created if res == b'': @@ -233,7 +233,7 @@ class TestNFS(MgrTestCase): Test if export or config object are deleted successfully. :param conf_obj: It denotes config object needs to be checked ''' - rados_obj_ls = self._sys_cmd(['rados', '-p', 'nfs-ganesha', '-N', self.cluster_id, 'ls']) + rados_obj_ls = self._sys_cmd(['rados', '-p', '.nfs', '-N', self.cluster_id, 'ls']) if b'export-' in rados_obj_ls or (conf_obj and b'conf-nfs' in rados_obj_ls): self.fail("Delete export failed") @@ -472,7 +472,7 @@ class TestNFS(MgrTestCase): ''' self._test_create_cluster() - pool = 'nfs-ganesha' + pool = '.nfs' user_id = 'test' fs_name = 'user_test_fs' pseudo_path = '/ceph' @@ -511,7 +511,7 @@ class TestNFS(MgrTestCase): self.assertEqual(config, res.decode('utf-8')) self._test_mnt(pseudo_path, port, ip) self._nfs_cmd('cluster', 'config', 'reset', self.cluster_id) - rados_obj_ls = self._sys_cmd(['rados', '-p', 'nfs-ganesha', '-N', self.cluster_id, 'ls']) + rados_obj_ls = self._sys_cmd(['rados', '-p', '.nfs', '-N', self.cluster_id, 'ls']) if b'conf-nfs' not in rados_obj_ls and b'userconf-nfs' in rados_obj_ls: self.fail("User config not deleted") time.sleep(30) diff --git a/src/pybind/mgr/cephadm/services/nfs.py b/src/pybind/mgr/cephadm/services/nfs.py index fdd4d7a59d315..0bdfe090c218d 100644 --- a/src/pybind/mgr/cephadm/services/nfs.py +++ b/src/pybind/mgr/cephadm/services/nfs.py @@ -6,6 +6,7 @@ import tempfile from typing import Dict, Tuple, Any, List, cast, Optional from mgr_module import HandleCommandResult +from mgr_module import NFS_POOL_NAME as POOL_NAME from ceph.deployment.service_spec import ServiceSpec, NFSServiceSpec @@ -13,9 +14,6 @@ from orchestrator import DaemonDescription from cephadm.services.cephadmservice import AuthEntity, CephadmDaemonDeploySpec, CephService - -POOL_NAME = 'nfs-ganesha' # make sure this matches pybind/mgr/nfs/nfs_utils.py - logger = logging.getLogger(__name__) diff --git a/src/pybind/mgr/mgr_module.py b/src/pybind/mgr/mgr_module.py index 83d3d59fc00b2..f7da34b771344 100644 --- a/src/pybind/mgr/mgr_module.py +++ b/src/pybind/mgr/mgr_module.py @@ -79,6 +79,8 @@ PG_STATES = [ "wait", ] +NFS_POOL_NAME = '.nfs' + class CommandResult(object): """ diff --git a/src/pybind/mgr/nfs/cluster.py b/src/pybind/mgr/nfs/cluster.py index 4e3c207e2b76c..6683891162fe3 100644 --- a/src/pybind/mgr/nfs/cluster.py +++ b/src/pybind/mgr/nfs/cluster.py @@ -4,12 +4,13 @@ import re import socket from typing import cast, Dict, List, Any, Union, Optional, TYPE_CHECKING, Tuple +from mgr_module import NFS_POOL_NAME as POOL_NAME from ceph.deployment.service_spec import NFSServiceSpec, PlacementSpec, IngressSpec import orchestrator from .exception import NFSInvalidOperation, ClusterNotFound -from .utils import POOL_NAME, available_clusters, restart_nfs_service +from .utils import available_clusters, restart_nfs_service from .export import NFSRados, exception_handler if TYPE_CHECKING: diff --git a/src/pybind/mgr/nfs/export.py b/src/pybind/mgr/nfs/export.py index 87d392e4d3716..b61392950cfbe 100644 --- a/src/pybind/mgr/nfs/export.py +++ b/src/pybind/mgr/nfs/export.py @@ -7,10 +7,12 @@ from os.path import normpath from rados import TimedOut, ObjectNotFound +from mgr_module import NFS_POOL_NAME as POOL_NAME + from .export_utils import GaneshaConfParser, Export, RawBlock, CephFSFSAL, RGWFSAL from .exception import NFSException, NFSInvalidOperation, FSNotFound, \ ClusterNotFound -from .utils import POOL_NAME, available_clusters, check_fs, restart_nfs_service +from .utils import available_clusters, check_fs, restart_nfs_service if TYPE_CHECKING: from nfs.module import Module diff --git a/src/pybind/mgr/nfs/tests/test_nfs.py b/src/pybind/mgr/nfs/tests/test_nfs.py index 3e1911d727975..c21139e4fbab9 100644 --- a/src/pybind/mgr/nfs/tests/test_nfs.py +++ b/src/pybind/mgr/nfs/tests/test_nfs.py @@ -83,13 +83,13 @@ EXPORT conf_nodeb = '%url "rados://ganesha/ns/export-1"' conf_nfs_foo = ''' -%url "rados://nfs-ganesha/foo/export-1" +%url "rados://.nfs/foo/export-1" -%url "rados://nfs-ganesha/foo/export-2"''' +%url "rados://.nfs/foo/export-2"''' clusters = { 'foo': { - 'pool': 'nfs-ganesha', + 'pool': '.nfs', 'namespace': 'foo', 'type': "ORCHESTRATOR", 'daemon_conf': 'conf-nfs.foo', @@ -166,9 +166,7 @@ EXPORT # mock nfs services cluster_info = self.clusters['foo'] orch_nfs_services = [ - ServiceDescription(spec=NFSServiceSpec(service_id='foo', - pool=cluster_info['pool'], - namespace=cluster_info['namespace'])) + ServiceDescription(spec=NFSServiceSpec(service_id='foo')) ] if enable else [] """ @@ -271,17 +269,17 @@ EXPORT "minor_versions": [1, 2] }), RawBlock('RADOS_KV', values={ - "pool": "nfs-ganesha", + "pool": ".nfs", "namespace": "vstart", "userid": "vstart", "nodeid": "a" }), RawBlock('RADOS_URLS', values={ "userid": "vstart", - "watch_url": "'rados://nfs-ganesha/vstart/conf-nfs.vstart'" + "watch_url": "'rados://.nfs/vstart/conf-nfs.vstart'" }), RawBlock('%url', values={ - "value": "rados://nfs-ganesha/vstart/conf-nfs.vstart" + "value": "rados://.nfs/vstart/conf-nfs.vstart" }) ] daemon_raw_config = """ @@ -302,7 +300,7 @@ NFS_CORE_PARAM { } RADOS_KV { - pool = nfs-ganesha; + pool = .nfs; namespace = vstart; UserId = vstart; nodeid = a; @@ -310,10 +308,10 @@ NFS_CORE_PARAM { RADOS_URLS { Userid = vstart; - watch_url = 'rados://nfs-ganesha/vstart/conf-nfs.vstart'; + watch_url = 'rados://.nfs/vstart/conf-nfs.vstart'; } - %url rados://nfs-ganesha/vstart/conf-nfs.vstart + %url rados://.nfs/vstart/conf-nfs.vstart """ daemon_config = GaneshaConfParser(daemon_raw_config).parse() assert daemon_config == expected_daemon_config diff --git a/src/pybind/mgr/nfs/utils.py b/src/pybind/mgr/nfs/utils.py index da7ca690b82e2..00552dfc0de12 100644 --- a/src/pybind/mgr/nfs/utils.py +++ b/src/pybind/mgr/nfs/utils.py @@ -5,8 +5,6 @@ import orchestrator if TYPE_CHECKING: from nfs.module import Module -POOL_NAME = 'nfs-ganesha' - def available_clusters(mgr: 'Module') -> List[str]: ''' diff --git a/src/pybind/mgr/rook/rook_cluster.py b/src/pybind/mgr/rook/rook_cluster.py index 49742369f7a88..daefe7a739468 100644 --- a/src/pybind/mgr/rook/rook_cluster.py +++ b/src/pybind/mgr/rook/rook_cluster.py @@ -23,6 +23,7 @@ from urllib3.exceptions import ProtocolError from ceph.deployment.drive_group import DriveGroupSpec from ceph.deployment.service_spec import ServiceSpec, NFSServiceSpec, RGWSpec from ceph.utils import datetime_now +from mgr_module import NFS_POOL_NAME from mgr_util import merge_dicts from typing import Optional, TypeVar, List, Callable, Any, cast, Generic, \ @@ -41,18 +42,14 @@ from .rook_client.ceph import cephobjectstore as cos from .rook_client.ceph import cephcluster as ccl from .rook_client._helper import CrdClass - import orchestrator - try: from rook.module import RookEnv except ImportError: pass # just used for type checking. -POOL_NAME = 'nfs-ganesha' # keep in sync with mgr/nfs/nfs_utils.py - T = TypeVar('T') FuncT = TypeVar('FuncT', bound=Callable) @@ -504,7 +501,7 @@ class RookCluster(object): spec=cnfs.Spec( rados=cnfs.Rados( namespace=self.rook_env.namespace, - pool=POOL_NAME, + pool=NFS_POOL_NAME, ), server=cnfs.Server( active=count diff --git a/src/python-common/ceph/deployment/service_spec.py b/src/python-common/ceph/deployment/service_spec.py index faa8674c11032..8af990431da17 100644 --- a/src/python-common/ceph/deployment/service_spec.py +++ b/src/python-common/ceph/deployment/service_spec.py @@ -663,7 +663,7 @@ yaml.add_representer(ServiceSpec, ServiceSpec.yaml_representer) class NFSServiceSpec(ServiceSpec): - DEFAULT_POOL = 'nfs-ganesha' + DEFAULT_POOL = '.nfs' def __init__(self, service_type: str = 'nfs', -- 2.39.5