unmount defaults to non-destructive mode

Summary:
This flips the sense of the unmount command; previously
we would default to destroying the mount and associated state,
but this was a bit of a massive sharp edge to our UX.

Now the default is non-destructive and you have to explicitly
pass in `--destroy` to enable destructive mode.

Reviewed By: chadaustin

Differential Revision: D6346013

fbshipit-source-id: ce612e7d8a70540d63217a97f96bc5760f3951af
This commit is contained in:
Wez Furlong 2017-11-16 09:04:33 -08:00 committed by Facebook Github Bot
parent 9217c5b56b
commit 06039c260f
4 changed files with 11 additions and 13 deletions

View File

@ -394,7 +394,7 @@ Do you want to run `eden mount %s` instead?''' % (path, path))
with self.get_thrift_client() as client:
client.mount(mount_info)
def unmount(self, path, delete_config=True):
def unmount(self, path, delete_config):
path = os.path.realpath(path)
with self.get_thrift_client() as client:
client.unmount(path)

View File

@ -166,7 +166,7 @@ def do_unmount(args):
args.path = normalize_path_arg(args.path)
config = create_config(args)
try:
return config.unmount(args.path, delete_config=not args.no_forget)
return config.unmount(args.path, delete_config=args.destroy)
except EdenService.EdenError as ex:
print_stderr('error: {}', ex)
return 1
@ -465,11 +465,9 @@ def create_parser():
unmount_parser = subparsers.add_parser(
'unmount', help='Unmount a specific client')
unmount_parser.add_argument(
'-n', '--no-forget',
'--destroy',
action='store_true',
help='Only unmount the client, without forgetting about its '
'configuration. The client can be re-mounted later using the mount '
'command.')
help='Permanently delete all state associated with the client.')
unmount_parser.add_argument(
'path', help='Path where client should be unmounted from')
unmount_parser.set_defaults(func=do_unmount)

View File

@ -208,8 +208,8 @@ class BasicTest:
entries)
self.assertTrue(self.eden.in_proc_mounts(self.mount))
# Unmount the client with --no-forget
self.eden.run_cmd('unmount', '-n', self.mount)
# do a normal user-facing unmount, preserving state
self.eden.run_cmd('unmount', self.mount)
self.assertFalse(self.eden.in_proc_mounts(self.mount))
entries = sorted(os.listdir(self.mount))
@ -227,10 +227,10 @@ class BasicTest:
self.assertEqual('foo!\n', f.read(), msg='overlay file is correct')
def test_double_unmount(self):
# Test calling "unmount -n" twice. The second should fail, but edenfs
# Test calling "unmount" twice. The second should fail, but edenfs
# should still work normally afterwards
self.eden.run_cmd('unmount', '-n', self.mount)
self.eden.run_unchecked('unmount', '-n', self.mount)
self.eden.run_cmd('unmount', self.mount)
self.eden.run_unchecked('unmount', self.mount)
# Now remount it with the mount command
self.eden.run_cmd('mount', self.mount)

View File

@ -233,9 +233,9 @@ class EdenFS(object):
def unmount(self, path):
'''
Run "eden unmount <path>"
Run "eden unmount --destroy <path>"
'''
self.run_cmd('unmount', path)
self.run_cmd('unmount', '--destroy', path)
def in_proc_mounts(self, mount_path):
'''Gets all eden mounts found in /proc/mounts, and returns