]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-disk: avoid remove '/var/lib/ceph/osd/ceph-xx' directory when deactive with... 16474/head
authorshun-s <song.shun3@zte.com.cn>
Fri, 21 Jul 2017 07:25:07 +0000 (15:25 +0800)
committerSong Shun <song.shun3@zte.com.cn>
Fri, 28 Jul 2017 10:23:37 +0000 (18:23 +0800)
  when using deactivate with --once, '/var/lib/ceph/osd/ceph-xx' will be deleted by call ** def unmount of ceph-disk**,
  resulting next activate failed. that's not what --once exactly wants.

Signed-off-by: Song Shun <song.shun3@zte.com.cn>
src/ceph-disk/ceph_disk/main.py
src/ceph-disk/tests/test_main.py

index 5ae5840b6ac894b5962f827d37fbce8cdf3794e0..a0cd91f54c495e3546de63ac80b6f8451164e828 100755 (executable)
@@ -1450,6 +1450,7 @@ def mount(
 
 def unmount(
     path,
+    do_rm=True,
 ):
     """
     Unmount and removes the given mount point.
@@ -1473,7 +1474,8 @@ def unmount(
             else:
                 time.sleep(0.5 + retries * 1.0)
                 retries += 1
-
+    if not do_rm:
+        return
     os.rmdir(path)
 
 
@@ -3942,7 +3944,7 @@ def main_deactivate_locked(args):
         with open(os.path.join(mounted_path, 'deactive'), 'w'):
             path_set_context(os.path.join(mounted_path, 'deactive'))
 
-    unmount(mounted_path)
+    unmount(mounted_path, do_rm=not args.once)
     LOG.info("Umount `%s` successfully.", mounted_path)
 
     if dmcrypt:
index ef6d7d4456e67af0911ab64d7a73bc26fb12d606..57e4af23bf32cb037a83770895a06c163e2eef66 100644 (file)
@@ -812,7 +812,7 @@ class TestCephDiskDeactivateAndDestroy(unittest.TestCase):
                 stop_daemon=lambda cluster, osd_id: True,
                 _remove_osd_directory_files=lambda path, cluster: True,
                 path_set_context=lambda path: True,
-                unmount=lambda path: True,
+                unmount=lambda path, do_rm: True,
                 dmcrypt_unmap=lambda part_uuid: True,
         ):
             main.main_deactivate(args)
@@ -846,7 +846,7 @@ class TestCephDiskDeactivateAndDestroy(unittest.TestCase):
                 stop_daemon=lambda cluster, osd_id: True,
                 _remove_osd_directory_files=lambda path, cluster: True,
                 path_set_context=lambda path: True,
-                unmount=lambda path: True,
+                unmount=lambda path, do_rm: True,
                 dmcrypt_unmap=lambda part_uuid: True,
         ):
             main.main_deactivate(args)