]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/rook: get running pods, auth rm, better error checking for orch nfs 43046/head
authorJoseph Sawaya <jsawaya@redhat.com>
Tue, 14 Sep 2021 18:54:41 +0000 (14:54 -0400)
committerJoseph Sawaya <jsawaya@redhat.com>
Wed, 10 Nov 2021 17:09:37 +0000 (12:09 -0500)
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 <jsawaya@redhat.com>
src/pybind/mgr/rook/module.py
src/pybind/mgr/rook/rook_cluster.py

index 028e801c224b5039bf67d75fd975097f25692cf8..e124f7e3c5e73ddb639dcfe11cbcb0376576e95d 100644 (file)
@@ -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]:
index 3c622d446ee52da33f937a1392273de6440f27a9..ab433e71ca9949b2f107682d3f63439f04035b7a 100644 (file)
@@ -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: