-from logging import error
+import datetime
import logging
+import re
import threading
import functools
import os
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
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,
),
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
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)
@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]:
"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: