From 8fcd1ebb4d8205efd4d0e18629d3e8a662a4f0ce Mon Sep 17 00:00:00 2001 From: Sophie Hallstedt Date: Fri, 25 Feb 2022 13:34:37 +0100 Subject: [PATCH] make cache timeout for gcs configurable --- docs/source/deploying/configuration.rst | 2 ++ environment.yml | 2 +- quetz/config.py | 2 ++ quetz/pkgstores.py | 2 ++ setup.cfg | 2 +- 5 files changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/source/deploying/configuration.rst b/docs/source/deploying/configuration.rst index 4a885a85..28620c82 100644 --- a/docs/source/deploying/configuration.rst +++ b/docs/source/deploying/configuration.rst @@ -162,11 +162,13 @@ Quetz can store packages in Google Cloud Storage. To configure, use the followin token = ".." bucket_prefix="..." bucket_suffix="..." + cache_timeout="..." :project: The Google Cloud Project ID to work under :token: A token to pass the `gcsfs`. See the `gcsfs documention `_ for valid values. :bucket_prefix: :bucket_suffix: channel buckets on GCS are created with the following semantics: ``{bucket_prefix}{channel_name}{bucket_suffix}`` +:cache_timeout: Timeout in s after which local GCS cache entries are invalidated. Set to a value <=0 to disable caching completely. Default is that entries are never invalidated. ``local_store`` section ^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/environment.yml b/environment.yml index 61a01b01..623949f3 100644 --- a/environment.yml +++ b/environment.yml @@ -27,7 +27,7 @@ dependencies: - alembic - zchunk - s3fs - - gcsfs >=2021.10.1 + - gcsfs >=2022.02 - sphinx - sphinx-book-theme - tenacity diff --git a/quetz/config.py b/quetz/config.py index ed29d9b2..7adc58cf 100644 --- a/quetz/config.py +++ b/quetz/config.py @@ -162,6 +162,7 @@ class Config: ConfigEntry("token", str, default=""), ConfigEntry("bucket_prefix", str, default=""), ConfigEntry("bucket_suffix", str, default=""), + ConfigEntry("cache_timeout", int, default=None), ], required=False, ), @@ -403,6 +404,7 @@ def get_package_store(self) -> pkgstores.PackageStore: 'token': self.gcs_token, 'bucket_prefix': self.gcs_bucket_prefix, 'bucket_suffix': self.gcs_bucket_suffix, + 'cache_timeout': self.gcs_cache_timeout, } ) else: diff --git a/quetz/pkgstores.py b/quetz/pkgstores.py index dcefeef6..2edac0aa 100644 --- a/quetz/pkgstores.py +++ b/quetz/pkgstores.py @@ -558,10 +558,12 @@ def __init__(self, config): self.project = config.get("project") self.token = config.get("token") + self.cache_timeout = config.get("cache_timeout") self.fs = gcsfs.GCSFileSystem( project=self.project, token=self.token if self.token else None, + cache_timeout=self.cache_timeout, ) self.bucket_prefix = config['bucket_prefix'] diff --git a/setup.cfg b/setup.cfg index 649f0eda..cfb91983 100644 --- a/setup.cfg +++ b/setup.cfg @@ -54,7 +54,7 @@ console_scripts = azure = adlfs gcs = - gcsfs >=2021.10.1 + gcsfs >=2022.02 pam = pamela postgre =