[ARVADOS] created: d5b49bc4f8749aabd97037614fcdc364b5254bb7
Git user
git at public.curoverse.com
Thu Oct 13 11:17:15 EDT 2016
at d5b49bc4f8749aabd97037614fcdc364b5254bb7 (commit)
commit d5b49bc4f8749aabd97037614fcdc364b5254bb7
Author: Lucas Di Pentima <lucas at curoverse.com>
Date: Thu Oct 13 12:14:55 2016 -0300
10236: Added --disable-event-listening to arv-mount command so that it doesn't subscribe to any API Server event.
Also, added a test for this new feature.
diff --git a/services/fuse/arvados_fuse/command.py b/services/fuse/arvados_fuse/command.py
index d15f017..3f89732 100644
--- a/services/fuse/arvados_fuse/command.py
+++ b/services/fuse/arvados_fuse/command.py
@@ -77,6 +77,8 @@ class ArgumentParser(argparse.ArgumentParser):
self.add_argument('--file-cache', type=int, help="File data cache size, in bytes (default 256MiB)", default=256*1024*1024)
self.add_argument('--directory-cache', type=int, help="Directory data cache size, in bytes (default 128MiB)", default=128*1024*1024)
+ self.add_argument('--disable-event-listening', action='store_true', help="Don't subscribe to events on the API server", dest="disable_event_listening", default=False)
+
self.add_argument('--read-only', action='store_false', help="Mount will be read only (default)", dest="enable_write", default=False)
self.add_argument('--read-write', action='store_true', help="Mount will be read-write", dest="enable_write", default=False)
@@ -111,7 +113,7 @@ class Mount(object):
def __enter__(self):
llfuse.init(self.operations, self.args.mountpoint, self._fuse_options())
- if self.listen_for_events:
+ if self.listen_for_events and not self.args.disable_event_listening:
self.operations.listen_for_events()
self.llfuse_thread = threading.Thread(None, lambda: self._llfuse_main())
self.llfuse_thread.daemon = True
@@ -330,7 +332,7 @@ From here, the following directories are available:
self.daemon_ctx.open()
# Subscribe to change events from API server
- if self.listen_for_events:
+ if self.listen_for_events and not self.args.disable_event_listening:
self.operations.listen_for_events()
self._llfuse_main()
diff --git a/services/fuse/tests/test_command_args.py b/services/fuse/tests/test_command_args.py
index bb80d0a..e8488d7 100644
--- a/services/fuse/tests/test_command_args.py
+++ b/services/fuse/tests/test_command_args.py
@@ -172,6 +172,20 @@ class MountArgsTest(unittest.TestCase):
@noexit
@mock.patch('arvados.events.subscribe')
+ def test_disable_event_listening(self, mock_subscribe):
+ args = arvados_fuse.command.ArgumentParser().parse_args([
+ '--disable-event-listening',
+ '--by-id',
+ '--foreground', self.mntdir])
+ self.mnt = arvados_fuse.command.Mount(args)
+ self.assertEqual(True, self.mnt.listen_for_events)
+ self.assertEqual(True, self.mnt.args.disable_event_listening)
+ with self.mnt:
+ pass
+ self.assertEqual(0, mock_subscribe.call_count)
+
+ @noexit
+ @mock.patch('arvados.events.subscribe')
def test_custom(self, mock_subscribe):
args = arvados_fuse.command.ArgumentParser().parse_args([
'--mount-tmp', 'foo',
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list