From 672e904b8145acc0f7588285c8051a92f8d75a80 Mon Sep 17 00:00:00 2001 From: Joseph Sawaya Date: Tue, 14 Sep 2021 14:54:41 -0400 Subject: [PATCH] mgr/rook: get running pods, auth rm, better error checking for orch nfs This commit updates orch ls to show the age and the number of running nfs pods, removes auth entities when removing an nfs service and implements better error checking when creating nfs daemons. Signed-off-by: Joseph Sawaya --- src/pybind/mgr/rook/module.py | 22 ++++++++++++++++++++-- src/pybind/mgr/rook/rook_cluster.py | 2 +- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/pybind/mgr/rook/module.py b/src/pybind/mgr/rook/module.py index 028e801c224b5..e124f7e3c5e73 100644 --- a/src/pybind/mgr/rook/module.py +++ b/src/pybind/mgr/rook/module.py @@ -1,5 +1,6 @@ -from logging import error +import datetime import logging +import re import threading import functools import os @@ -348,6 +349,7 @@ class RookOrchestrator(MgrModule, orchestrator.Orchestrator): if service_type == 'nfs' or service_type is None: # CephNFSes all_nfs = self.rook_cluster.get_resource("cephnfses") + nfs_pods = self.rook_cluster.describe_pods('nfs', None, None) for nfs in all_nfs: if nfs['spec']['rados']['pool'] != NFS_POOL_NAME: continue @@ -356,6 +358,7 @@ class RookOrchestrator(MgrModule, orchestrator.Orchestrator): if svc in spec: continue active = nfs['spec'].get('server', {}).get('active') + creation_timestamp = datetime.datetime.strptime(nfs['metadata']['creationTimestamp'], '%Y-%m-%dT%H:%M:%SZ') spec[svc] = orchestrator.ServiceDescription( spec=NFSServiceSpec( service_id=nfs_name, @@ -363,6 +366,8 @@ class RookOrchestrator(MgrModule, orchestrator.Orchestrator): ), size=active, last_refresh=now, + running=len([1 for pod in nfs_pods if pod['labels']['ceph_nfs'] == nfs_name]), + created=creation_timestamp.astimezone(tz=datetime.timezone.utc) ) if service_type == 'osd' or service_type is None: # OSDs @@ -506,6 +511,15 @@ class RookOrchestrator(MgrModule, orchestrator.Orchestrator): elif service_type == 'rgw': return self.rook_cluster.rm_service('cephobjectstores', service_id) elif service_type == 'nfs': + ret, out, err = self.mon_command({ + 'prefix': 'auth ls' + }) + matches = re.findall(rf'client\.nfs-ganesha\.{service_id}\..*', out) + for match in matches: + self.check_mon_command({ + 'prefix': 'auth rm', + 'entity': match + }) return self.rook_cluster.rm_service('cephnfses', service_id) elif service_type == 'rbd-mirror': return self.rook_cluster.rm_service('cephrbdmirrors', service_id) @@ -558,7 +572,11 @@ class RookOrchestrator(MgrModule, orchestrator.Orchestrator): @handle_orch_error def apply_nfs(self, spec): # type: (NFSServiceSpec) -> str - return self.rook_cluster.apply_nfsgw(spec, self) + try: + return self.rook_cluster.apply_nfsgw(spec, self) + except Exception as e: + logging.error(e) + return "Unable to create NFS daemon, check logs for more traceback\n" + str(e.with_traceback(None)) @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 3c622d446ee52..ab433e71ca994 100644 --- a/src/pybind/mgr/rook/rook_cluster.py +++ b/src/pybind/mgr/rook/rook_cluster.py @@ -776,7 +776,7 @@ class RookCluster(object): "osd": ("ceph-osd-id", service_id), "mon": ("mon", service_id), "mgr": ("mgr", service_id), - "ceph_nfs": ("ceph_nfs", service_id), + "nfs": ("nfs", service_id), "rgw": ("ceph_rgw", service_id), }[service_type] except KeyError: -- 2.47.3