From: Varsha Rao Date: Thu, 14 May 2020 13:46:35 +0000 (+0530) Subject: mgr/volumes/nfs: Delete all exports on cluster deletion X-Git-Tag: v16.1.0~2196^2~12 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d12aed8eeaaa981873aa278d8bdb209e3f6968c9;p=ceph.git mgr/volumes/nfs: Delete all exports on cluster deletion Signed-off-by: Varsha Rao --- diff --git a/src/pybind/mgr/volumes/fs/nfs.py b/src/pybind/mgr/volumes/fs/nfs.py index 8b1fa8ac2af7..e1bc490189a1 100644 --- a/src/pybind/mgr/volumes/fs/nfs.py +++ b/src/pybind/mgr/volumes/fs/nfs.py @@ -344,10 +344,14 @@ class FSExport(object): return (0, json.dumps(result, indent=4), '') - def delete_export(self, pseudo_path, cluster_id): + def delete_export(self, pseudo_path, cluster_id, export_obj=None): try: self.rados_namespace = cluster_id - export = self._fetch_export(pseudo_path) + if export_obj: + export = export_obj + else: + export = self._fetch_export(pseudo_path) + if export: common_conf = 'conf-nfs.ganesha-{}'.format(cluster_id) self._delete_export_url(common_conf, export.export_id) @@ -360,6 +364,12 @@ class FSExport(object): return 0, "", "Successfully deleted export" + def delete_all_exports(self, cluster_id): + export_list = list(self.exports[cluster_id]) + for export in export_list: + self.delete_export(None, cluster_id, export) + log.info(f"All exports successfully deleted for cluster id: {cluster_id}") + def make_rados_url(self, obj): if self.rados_namespace: return "rados://{}/{}/{}".format(self.rados_pool, self.rados_namespace, obj) @@ -452,6 +462,7 @@ class NFSCluster: self._set_cluster_id(cluster_id) if self.check_cluster_exists(): try: + self.mgr.fs_export.delete_all_exports(cluster_id) completion = self.mgr.remove_service('nfs.' + self.cluster_id) self.mgr._orchestrator_wait([completion]) orchestrator.raise_if_exception(completion)