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 494c15cb9d
Disable cleanup thread in set_metadata.py 6a56f3a5de
Fix S3 object store shutdown 7a63fd1db2
This commit is contained in:
Uehara.Keizo
2021-12-23 01:32:16 +00:00
parent bf58b5cc30
commit 992f18e127
2 changed files with 23 additions and 8 deletions
+21 -8
View File
@@ -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)
@@ -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