From: shun-s Date: Fri, 21 Jul 2017 07:25:07 +0000 (+0800) Subject: ceph-disk: avoid remove '/var/lib/ceph/osd/ceph-xx' directory when deactive with... X-Git-Tag: ses5-milestone10~6^2~6^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2a53531e5e278d26ccf8e4afd2fcf2b72f86a0ae;p=ceph.git ceph-disk: avoid remove '/var/lib/ceph/osd/ceph-xx' directory when deactive with --once 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 --- diff --git a/src/ceph-disk/ceph_disk/main.py b/src/ceph-disk/ceph_disk/main.py index 5ae5840b6ac8..a0cd91f54c49 100755 --- a/src/ceph-disk/ceph_disk/main.py +++ b/src/ceph-disk/ceph_disk/main.py @@ -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: diff --git a/src/ceph-disk/tests/test_main.py b/src/ceph-disk/tests/test_main.py index ef6d7d4456e6..57e4af23bf32 100644 --- a/src/ceph-disk/tests/test_main.py +++ b/src/ceph-disk/tests/test_main.py @@ -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)