Skip to content

Commit

Permalink
mgr/rook: get running pods, auth rm, better error checking for orch nfs
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Joseph Sawaya committed Nov 10, 2021
1 parent 2c803ec commit 672e904
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
22 changes: 20 additions & 2 deletions 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
Expand Down Expand Up @@ -348,6 +349,7 @@ def describe_service(self,
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
Expand All @@ -356,13 +358,16 @@ def describe_service(self,
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,
placement=PlacementSpec(count=active),
),
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
Expand Down Expand Up @@ -506,6 +511,15 @@ def remove_service(self, service_name: str, force: bool = False) -> str:
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)
Expand Down Expand Up @@ -558,7 +572,11 @@ def apply_rgw(self, spec):
@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]:
Expand Down
2 changes: 1 addition & 1 deletion src/pybind/mgr/rook/rook_cluster.py
Expand Up @@ -776,7 +776,7 @@ def predicate(item):
"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:
Expand Down

0 comments on commit 672e904

Please sign in to comment.