]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: fix the error when exporting CephFS path "/" in NFS exports 37154/head
authorKiefer Chang <kiefer.chang@suse.com>
Tue, 15 Sep 2020 08:27:44 +0000 (16:27 +0800)
committerKiefer Chang <kiefer.chang@suse.com>
Tue, 15 Sep 2020 09:24:43 +0000 (17:24 +0800)
Fixes: https://tracker.ceph.com/issues/47397
Signed-off-by: Kiefer Chang <kiefer.chang@suse.com>
qa/tasks/mgr/dashboard/test_ganesha.py
src/pybind/mgr/dashboard/services/ganesha.py

index c99e3651ff1442185681b6d2ee378a3bdd7e3a6e..d02e4f6edac315d59d5d97f70ad29cf6aa7632a9 100644 (file)
@@ -68,7 +68,7 @@ class GaneshaTest(DashboardTestCase):
     @classmethod
     def create_export(cls, path, cluster_id, daemons, fsal, sec_label_xattr=None):
         if fsal == 'CEPH':
-            fsal = {"name": "CEPH", "user_id":"admin", "fs_name": None, "sec_label_xattr": sec_label_xattr}
+            fsal = {"name": "CEPH", "user_id": "admin", "fs_name": None, "sec_label_xattr": sec_label_xattr}
             pseudo = "/cephfs{}".format(path)
         else:
             fsal = {"name": "RGW", "rgw_user_id": "admin"}
@@ -86,7 +86,7 @@ class GaneshaTest(DashboardTestCase):
             "protocols": [4],
             "transports": ["TCP"],
             "clients": [{
-                "addresses":["10.0.0.0/8"],
+                "addresses": ["10.0.0.0/8"],
                 "access_type": "RO",
                 "squash": "root"
             }]
@@ -103,19 +103,25 @@ class GaneshaTest(DashboardTestCase):
             self._task_delete("/api/nfs-ganesha/export/{}/{}"
                               .format(exp['cluster_id'], exp['export_id']))
 
-    def test_create_export(self):
+    def _test_create_export(self, cephfs_path):
         exports = self._get("/api/nfs-ganesha/export")
         self.assertEqual(len(exports), 0)
 
-        data = self.create_export("/foo", 'cluster1', ['node1', 'node2'], 'CEPH', "security.selinux")
+        data = self.create_export(cephfs_path, 'cluster1', ['node1', 'node2'], 'CEPH', "security.selinux")
 
         exports = self._get("/api/nfs-ganesha/export")
         self.assertEqual(len(exports), 1)
         self.assertDictEqual(exports[0], data)
         return data
 
+    def test_create_export(self):
+        self._test_create_export('/foo')
+
+    def test_create_export_for_cephfs_root(self):
+        self._test_create_export('/')
+
     def test_update_export(self):
-        export = self.test_create_export()
+        export = self._test_create_export('/foo')
         export['access_type'] = 'RO'
         export['daemons'] = ['node1', 'node3']
         export['security_label'] = True
@@ -129,7 +135,7 @@ class GaneshaTest(DashboardTestCase):
         self.assertEqual(exports[0]['security_label'], True)
 
     def test_delete_export(self):
-        export = self.test_create_export()
+        export = self._test_create_export('/foo')
         self._task_delete("/api/nfs-ganesha/export/{}/{}"
                           .format(export['cluster_id'], export['export_id']))
         self.assertStatus(204)
index c5fc4aa63eee5ebec519f7279ecc89a00181167f..78083f610382b7360caa3025a12bae54ec398785 100644 (file)
@@ -3,6 +3,7 @@
 from __future__ import absolute_import
 
 import logging
+import os
 import re
 
 from orchestrator import OrchestratorError
@@ -491,6 +492,8 @@ class CephFSFSal(FSal):
 
     def create_path(self, path):
         cfs = CephFS(self.fs_name)
+        if path == os.sep:
+            return
         cfs.mk_dirs(path)
 
     @classmethod