From 992f18e1274d7604074f4098e3ba5ddf478e17bf Mon Sep 17 00:00:00 2001 From: "Uehara.Keizo" Date: Thu, 23 Dec 2021 01:32:16 +0000 Subject: [PATCH] Disable cleanup thread of cloud objectstore in set_metadata.py Apply the following fixes for s3.py to cloud.py Be more explcit about starting cache monitor thread 494c15cb9d622c3c75bbcf72b880ee386cbe01f5 Disable cleanup thread in set_metadata.py 6a56f3a5deb51dd1fafa8c588f32b14e67d10245 Fix S3 object store shutdown 7a63fd1db202a9993c09cb6f10c0615dc8dc5c99 --- lib/galaxy/objectstore/cloud.py | 29 ++++++++++++++++------- test/unit/objectstore/test_objectstore.py | 2 ++ 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/lib/galaxy/objectstore/cloud.py b/lib/galaxy/objectstore/cloud.py index 9b19a4fcc5b..867d1cba89d 100644 --- a/lib/galaxy/objectstore/cloud.py +++ b/lib/galaxy/objectstore/cloud.py @@ -57,7 +57,8 @@ class CloudConfigMixin: "cache": { "size": self.cache_size, "path": self.staging_path, - } + }, + 'enable_cache_monitor': False, } @@ -76,6 +77,7 @@ class Cloud(ConcreteObjectStore, CloudConfigMixin): bucket_dict = config_dict['bucket'] connection_dict = config_dict.get('connection', {}) cache_dict = config_dict['cache'] + self.enable_cache_monitor = config_dict.get('enable_cache_monitor', True) self.provider = config_dict["provider"] self.credentials = config_dict["auth"] @@ -100,8 +102,17 @@ class Cloud(ConcreteObjectStore, CloudConfigMixin): self.conn = self._get_connection(self.provider, self.credentials) self.bucket = self._get_bucket(self.bucket_name) + self.start_cache_monitor() + # Test if 'axel' is available for parallel download and pull the key into cache + try: + subprocess.call('axel') + self.use_axel = True + except OSError: + self.use_axel = False + + def start_cache_monitor(self): # Clean cache only if value is set in galaxy.ini - if self.cache_size != -1: + if self.cache_size != -1 and self.enable_cache_monitor: # Convert GBs to bytes for comparison self.cache_size = self.cache_size * 1073741824 # Helper for interruptable sleep @@ -109,12 +120,6 @@ class Cloud(ConcreteObjectStore, CloudConfigMixin): self.cache_monitor_thread = threading.Thread(target=self.__cache_monitor) self.cache_monitor_thread.start() log.info("Cache cleaner manager started") - # Test if 'axel' is available for parallel download and pull the key into cache - try: - subprocess.call('axel') - self.use_axel = True - except OSError: - self.use_axel = False @staticmethod def _get_connection(provider, credentials): @@ -710,3 +715,11 @@ class Cloud(ConcreteObjectStore, CloudConfigMixin): def _get_store_usage_percent(self): return 0.0 + + def shutdown(self): + self.running = False + thread = getattr(self, 'cache_monitor_thread', None) + if thread: + log.debug("Shutting down thread") + self.sleeper.wake() + thread.join(5) diff --git a/test/unit/objectstore/test_objectstore.py b/test/unit/objectstore/test_objectstore.py index 25a3ad20bf0..83e5306a257 100644 --- a/test/unit/objectstore/test_objectstore.py +++ b/test/unit/objectstore/test_objectstore.py @@ -723,6 +723,8 @@ def test_config_parse_cloud(): _assert_key_has_value(cache_dict, "size", 1000.0) _assert_key_has_value(cache_dict, "path", "database/object_store_cache") + _assert_key_has_value(as_dict, "enable_cache_monitor", False) + extra_dirs = as_dict["extra_dirs"] assert len(extra_dirs) == 2