mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Remove quotes from s3fs ETag entries
This causes md5 comparisons to fail and makes the master think it needs to re-download every file.
This commit is contained in:
parent
bf2950453d
commit
daf7f94907
@ -79,8 +79,8 @@ import salt.utils.s3 as s3
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
_s3_cache_expire = 30 # cache for 30 seconds
|
||||
_s3_sync_on_update = True # sync cache on update rather than jit
|
||||
S3_CACHE_EXPIRE = 30 # cache for 30 seconds
|
||||
S3_SYNC_ON_UPDATE = True # sync cache on update rather than jit
|
||||
|
||||
|
||||
def envs():
|
||||
@ -101,7 +101,7 @@ def update():
|
||||
|
||||
metadata = _init()
|
||||
|
||||
if _s3_sync_on_update:
|
||||
if S3_SYNC_ON_UPDATE:
|
||||
# sync the buckets to the local cache
|
||||
log.info('Syncing local cache from S3...')
|
||||
for saltenv, env_meta in metadata.iteritems():
|
||||
@ -328,18 +328,19 @@ def _init():
|
||||
Connect to S3 and download the metadata for each file in all buckets
|
||||
specified and cache the data to disk.
|
||||
'''
|
||||
|
||||
cache_file = _get_buckets_cache_filename()
|
||||
exp = time.time() - _s3_cache_expire
|
||||
|
||||
metadata = None
|
||||
exp = time.time() - S3_CACHE_EXPIRE
|
||||
|
||||
# check mtime of the buckets files cache
|
||||
if os.path.isfile(cache_file) and os.path.getmtime(cache_file) > exp:
|
||||
metadata = _read_buckets_cache_file(cache_file)
|
||||
metadata = None
|
||||
try:
|
||||
if os.path.getmtime(cache_file) > exp:
|
||||
metadata = _read_buckets_cache_file(cache_file)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
if metadata is None:
|
||||
# bucket files cache expired
|
||||
# bucket files cache expired or does not exist
|
||||
metadata = _refresh_buckets_cache_file(cache_file)
|
||||
|
||||
return metadata
|
||||
@ -520,13 +521,17 @@ def _find_file_meta(metadata, bucket_name, saltenv, path):
|
||||
'''
|
||||
Looks for a file's metadata in the S3 bucket cache file
|
||||
'''
|
||||
|
||||
env_meta = metadata[saltenv] if saltenv in metadata else {}
|
||||
bucket_meta = env_meta[bucket_name] if bucket_name in env_meta else {}
|
||||
files_meta = filter((lambda k: 'Key' in k), bucket_meta)
|
||||
|
||||
for item_meta in files_meta:
|
||||
if 'Key' in item_meta and item_meta['Key'] == path:
|
||||
try:
|
||||
# Get rid of quotes surrounding md5
|
||||
item_meta['ETag'] = item_meta['ETag'].strip('"')
|
||||
except KeyError:
|
||||
pass
|
||||
return item_meta
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user