[ARVADOS] updated: 1.3.0-2143-g209ff863b

Git user git at public.arvados.org
Wed Feb 12 15:48:37 UTC 2020


Summary of changes:
 sdk/python/arvados/util.py            |  3 +++
 services/fuse/arvados_fuse/fusedir.py | 24 +++++++++++++++++++-----
 services/fuse/tests/test_mount.py     | 24 ++++++++++++++++++++++--
 3 files changed, 44 insertions(+), 7 deletions(-)

       via  209ff863b0659851e6eeae6d5405a02df906322f (commit)
       via  cfcfab92f12cf26e5a5b55d5a473408098599283 (commit)
      from  487e8f756d63c6e68eb300a559eccb504f78c40b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 209ff863b0659851e6eeae6d5405a02df906322f
Author: Tom Clegg <tom at tomclegg.ca>
Date:   Wed Feb 12 10:48:05 2020 -0500

    16039: Fix & add test for sanitized/unsanitized name conflict.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at tomclegg.ca>

diff --git a/services/fuse/arvados_fuse/fusedir.py b/services/fuse/arvados_fuse/fusedir.py
index 3f6430973..8b12f73e8 100644
--- a/services/fuse/arvados_fuse/fusedir.py
+++ b/services/fuse/arvados_fuse/fusedir.py
@@ -941,7 +941,7 @@ class ProjectDirectory(Directory):
                                                                 namefilter],
                                                        limit=2).execute(num_retries=self.num_retries)["items"]
         if contents:
-            if len(contents) > 1 and contents[1].name == k:
+            if len(contents) > 1 and contents[1]['name'] == k:
                 # If "foo/bar" and "foo[SUBST]bar" both exist, use
                 # "foo[SUBST]bar".
                 contents = [contents[1]]
diff --git a/services/fuse/tests/test_mount.py b/services/fuse/tests/test_mount.py
index 1e63b9f4d..593d945cf 100644
--- a/services/fuse/tests/test_mount.py
+++ b/services/fuse/tests/test_mount.py
@@ -1239,3 +1239,17 @@ class SlashSubstitutionTest(IntegrationTest):
     def checkContents(self):
         self.assertRegexpMatches(self.api.collections().get(uuid=self.testcoll['uuid']).execute()['manifest_text'], ' acbd18db') # md5(foo)
         self.assertRegexpMatches(self.api.collections().get(uuid=self.testcolleasy['uuid']).execute()['manifest_text'], ' f561aaf6') # md5(xxx)
+
+    @IntegrationTest.mount(argv=mnt_args)
+    @mock.patch('arvados.util.get_config_once')
+    def test_slash_substitution_conflict(self, get_config_once):
+        self.testcollconflict = self.api.collections().create(body={"name": self.fusename}).execute()
+        get_config_once.return_value = {"Collections": {"ForwardSlashNameSubstitution": "[SLASH]"}}
+        self.pool_test(os.path.join(self.mnt, 'zzz'), self.fusename)
+        self.assertRegexpMatches(self.api.collections().get(uuid=self.testcollconflict['uuid']).execute()['manifest_text'], ' acbd18db') # md5(foo)
+        # foo/bar/baz collection unchanged, because it is masked by foo[SLASH]bar[SLASH]baz
+        self.assertEqual(self.api.collections().get(uuid=self.testcoll['uuid']).execute()['manifest_text'], '')
+    @staticmethod
+    def _test_slash_substitution_conflict(self, tmpdir, fusename):
+        with open(os.path.join(tmpdir, fusename, 'waz'), 'w') as f:
+            f.write('foo')

commit cfcfab92f12cf26e5a5b55d5a473408098599283
Author: Tom Clegg <tom at tomclegg.ca>
Date:   Wed Feb 12 10:37:48 2020 -0500

    16039: Accommodate API servers with no config export.
    
    Add more checks in test cases.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at tomclegg.ca>

diff --git a/sdk/python/arvados/util.py b/sdk/python/arvados/util.py
index b27b64e59..9e0a31783 100644
--- a/sdk/python/arvados/util.py
+++ b/sdk/python/arvados/util.py
@@ -421,6 +421,9 @@ def new_request_id():
     return rid
 
 def get_config_once(svc):
+    if not svc._rootDesc.get('resources')['configs']:
+        # Old API server version, no config export endpoint
+        return {}
     if not hasattr(svc, '_cached_config'):
         svc._cached_config = svc.configs().get().execute()
     return svc._cached_config
diff --git a/services/fuse/arvados_fuse/fusedir.py b/services/fuse/arvados_fuse/fusedir.py
index 9853f6ac2..3f6430973 100644
--- a/services/fuse/arvados_fuse/fusedir.py
+++ b/services/fuse/arvados_fuse/fusedir.py
@@ -55,10 +55,24 @@ class Directory(FreshBase):
         self._entries = {}
         self._mtime = time.time()
 
+    def forward_slash_subst(self):
+        if not hasattr(self, '_fsns'):
+            self._fsns = None
+            config = self.apiconfig()
+            try:
+                self._fsns = config["Collections"]["ForwardSlashNameSubstitution"]
+            except KeyError:
+                # old API server with no FSNS config
+                self._fsns = '_'
+            else:
+                if self._fsns == '' or self._fsns == '/':
+                    self._fsns = None
+        return self._fsns
+
     def unsanitize_filename(self, incoming):
         """Replace ForwardSlashNameSubstitution value with /"""
-        fsns = self.apiconfig()["Collections"]["ForwardSlashNameSubstitution"]
-        if isinstance(fsns, str) and fsns != '' and fsns != '/':
+        fsns = self.forward_slash_subst()
+        if isinstance(fsns, str):
             return incoming.replace(fsns, '/')
         else:
             return incoming
@@ -76,8 +90,8 @@ class Directory(FreshBase):
         elif dirty == '..':
             return '__'
         else:
-            fsns = self.apiconfig()["Collections"]["ForwardSlashNameSubstitution"]
-            if isinstance(fsns, str) and fsns != '':
+            fsns = self.forward_slash_subst()
+            if isinstance(fsns, str):
                 dirty = dirty.replace('/', fsns)
             return _disallowed_filename_characters.sub('_', dirty)
 
diff --git a/services/fuse/tests/test_mount.py b/services/fuse/tests/test_mount.py
index 3ec03fa22..1e63b9f4d 100644
--- a/services/fuse/tests/test_mount.py
+++ b/services/fuse/tests/test_mount.py
@@ -1214,10 +1214,11 @@ class SlashSubstitutionTest(IntegrationTest):
     def test_slash_substitution_before_listing(self, get_config_once):
         get_config_once.return_value = {"Collections": {"ForwardSlashNameSubstitution": "[SLASH]"}}
         self.pool_test(os.path.join(self.mnt, 'zzz'), self.fusename)
+        self.checkContents()
     @staticmethod
     def _test_slash_substitution_before_listing(self, tmpdir, fusename):
         with open(os.path.join(tmpdir, 'foo-bar-baz', 'waz'), 'w') as f:
-            f.write('foo')
+            f.write('xxx')
         with open(os.path.join(tmpdir, fusename, 'waz'), 'w') as f:
             f.write('foo')
 
@@ -1226,10 +1227,15 @@ class SlashSubstitutionTest(IntegrationTest):
     def test_slash_substitution_after_listing(self, get_config_once):
         get_config_once.return_value = {"Collections": {"ForwardSlashNameSubstitution": "[SLASH]"}}
         self.pool_test(os.path.join(self.mnt, 'zzz'), self.fusename)
+        self.checkContents()
     @staticmethod
     def _test_slash_substitution_after_listing(self, tmpdir, fusename):
         with open(os.path.join(tmpdir, 'foo-bar-baz', 'waz'), 'w') as f:
-            f.write('foo')
+            f.write('xxx')
         os.listdir(tmpdir)
         with open(os.path.join(tmpdir, fusename, 'waz'), 'w') as f:
             f.write('foo')
+
+    def checkContents(self):
+        self.assertRegexpMatches(self.api.collections().get(uuid=self.testcoll['uuid']).execute()['manifest_text'], ' acbd18db') # md5(foo)
+        self.assertRegexpMatches(self.api.collections().get(uuid=self.testcolleasy['uuid']).execute()['manifest_text'], ' f561aaf6') # md5(xxx)

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list