diff --git a/SAS/DataManagement/StorageQueryService/cache.py b/SAS/DataManagement/StorageQueryService/cache.py index e799c1c48bbe1e83a74b11e9ac7cd182492853af..be1626146f3502d7297dae9f30325aa65d0e97ca 100644 --- a/SAS/DataManagement/StorageQueryService/cache.py +++ b/SAS/DataManagement/StorageQueryService/cache.py @@ -123,7 +123,7 @@ class CacheManager: if du_result['found']: if not path in path_cache or path_cache[path]['disk_usage'] != du_result['disk_usage']: - logger.debug('updating cache entry: %s', du_result) + logger.info('updating cache entry: %s', du_result) path_cache[path] = du_result self._sendDiskUsageChangedNotification(path, du_result['disk_usage'], otdb_id) @@ -161,7 +161,7 @@ class CacheManager: with self._cacheLock: path_cache = self._cache['path_du_results'] - if directory not in path_cache: + if not directory in path_cache: logger.info('tree scan: adding \'%s\' with empty disk_usage to cache which will be du\'ed later', directory) empty_du_result = {'found': True, 'disk_usage': None, 'path': directory, 'name': directory.split('/')[-1]} self._updateCache(empty_du_result) @@ -211,6 +211,10 @@ class CacheManager: if depth1 == 2 or depth2 == 2: if depth1 == 2 and depth2 == 2: + if not entry1['disk_usage']: + return -1 + if not entry2['disk_usage']: + return 1 if entry1['cache_timestamp'] < entry2['cache_timestamp']: return -1 if entry1['cache_timestamp'] > entry2['cache_timestamp']: @@ -242,7 +246,7 @@ class CacheManager: logger.info('examining old entry %s/%s in cache: %s', i, len(old_entries), path) result = du_getDiskUsageForPath(path) if result['found']: - logger.info('updating old entry in cache: %s', result) + logger.debug('trying to update old entry in cache: %s', result) self._updateCache(result) except Exception as e: logger.error(str(e)) @@ -253,7 +257,7 @@ class CacheManager: if datetime.datetime.utcnow() - cacheUpdateStart > datetime.timedelta(minutes=5): # break out of cache update loop if full update takes more than 5min # next loop we'll start with the oldest cache entries again - logger.info('skipping remaining old cache entries updates, they will be updated next time') + logger.info('skipping remaining %s old cache entries updates, they will be updated next time', len(old_entries)-i) break for i in range(60): diff --git a/SAS/ResourceAssignment/ResourceAssignmentEditor/lib/storage.py b/SAS/ResourceAssignment/ResourceAssignmentEditor/lib/storage.py index 6a91bdd368490a0482d3f584c1393bb1e44455da..2075f3458ea882cd324cf49c59e86ffa8a3ca9e9 100644 --- a/SAS/ResourceAssignment/ResourceAssignmentEditor/lib/storage.py +++ b/SAS/ResourceAssignment/ResourceAssignmentEditor/lib/storage.py @@ -31,16 +31,15 @@ import logging logger = logging.getLogger(__name__) def updateTaskStorageDetails(tasks, sqrpc): + if not tasks: + return + def applyDefaults(task): '''apply sane default values for a task''' task['disk_usage'] = None task['disk_usage_readable'] = None - try: - _ = (t for t in tasks) - except TypeError: - # make single task instance a list - tasks = [tasks] + tasks = tasks if isinstance(tasks, list) else [tasks] for task in tasks: applyDefaults(task)