X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/be4c2feb3d9ba3c2631d78e68bc5ed2945c17cab..cf9b56161704477075cda297b44dae4d9342c24a:/services/fuse/arvados_fuse/__init__.py diff --git a/services/fuse/arvados_fuse/__init__.py b/services/fuse/arvados_fuse/__init__.py index c3f913e961..d5523e8083 100644 --- a/services/fuse/arvados_fuse/__init__.py +++ b/services/fuse/arvados_fuse/__init__.py @@ -19,16 +19,10 @@ import logging import time import calendar import threading +from arvados.util import portable_data_hash_pattern, uuid_pattern, collection_uuid_pattern, group_uuid_pattern, user_uuid_pattern, link_uuid_pattern _logger = logging.getLogger('arvados.arvados_fuse') -portable_data_hash_pattern = re.compile(r'[0-9a-f]{32}\+\d+') -uuid_pattern = re.compile(r'[a-z0-9]{5}-[a-z0-9]{5}-[a-z0-9]{15}') -collection_uuid_pattern = re.compile(r'[a-z0-9]{5}-4zz18-[a-z0-9]{15}') -group_uuid_pattern = re.compile(r'[a-z0-9]{5}-j7d0g-[a-z0-9]{15}') -user_uuid_pattern = re.compile(r'[a-z0-9]{5}-tpzed-[a-z0-9]{15}') -link_uuid_pattern = re.compile(r'[a-z0-9]{5}-o0j2j-[a-z0-9]{15}') - class SafeApi(object): '''Threadsafe wrapper for API object. This stores and returns a different api object per thread, because httplib2 which underlies apiclient is not @@ -37,26 +31,29 @@ class SafeApi(object): def __init__(self, config): self.host = config.get('ARVADOS_API_HOST') - self.token = config.get('ARVADOS_API_TOKEN') + self.api_token = config.get('ARVADOS_API_TOKEN') self.insecure = config.flag_is_true('ARVADOS_API_HOST_INSECURE') self.local = threading.local() + self.block_cache = arvados.KeepBlockCache() def localapi(self): if 'api' not in self.local.__dict__: - self.local.api = arvados.api('v1', False, self.host, self.token, self.insecure) + self.local.api = arvados.api('v1', False, self.host, + self.api_token, self.insecure) return self.local.api - def collections(self): - return self.localapi().collections() - - def links(self): - return self.localapi().links() + def localkeep(self): + if 'keep' not in self.local.__dict__: + self.local.keep = arvados.KeepClient(api_client=self.localapi(), block_cache=self.block_cache) + return self.local.keep - def groups(self): - return self.localapi().groups() + def __getattr__(self, name): + # Proxy nonexistent attributes to the local API client. + try: + return getattr(self.localapi(), name) + except AttributeError: + return super(SafeApi, self).__getattr__(name) - def users(self): - return self.localapi().users() def convertTime(t): '''Parse Arvados timestamp to unix time.''' @@ -313,7 +310,7 @@ class CollectionDirectory(Directory): self.collection_object_file.update(self.collection_object) self.clear() - collection = arvados.CollectionReader(self.collection_object["manifest_text"], self.api) + collection = arvados.CollectionReader(self.collection_object["manifest_text"], self.api, self.api.localkeep()) for s in collection.all_streams(): cwd = self for part in s.name().split('/'): @@ -347,6 +344,10 @@ class CollectionDirectory(Directory): else: _logger.error("arv-mount %s: error", self.collection_locator) _logger.exception(detail) + except arvados.errors.ArgumentError as detail: + _logger.warning("arv-mount %s: error %s", self.collection_locator, detail) + if self.collection_object is not None and "manifest_text" in self.collection_object: + _logger.warning("arv-mount manifest_text is: %s", self.collection_object["manifest_text"]) except Exception as detail: _logger.error("arv-mount %s: error", self.collection_locator) if self.collection_object is not None and "manifest_text" in self.collection_object: @@ -802,7 +803,11 @@ class Operations(llfuse.Operations): try: with llfuse.lock_released: return handle.entry.readfrom(off, size) - except: + except arvados.errors.NotFoundError as e: + _logger.warning("Block not found: " + str(e)) + raise llfuse.FUSEError(errno.EIO) + except Exception as e: + _logger.exception(e) raise llfuse.FUSEError(errno.EIO) def release(self, fh):