Skip to content

Commit

Permalink
s3fs: add settings for hardcoded parameters S3_SYNC_ON_UPDATE and S3_…
Browse files Browse the repository at this point in the history
…CACHE_EXPIRE
  • Loading branch information
hurzhurz committed Nov 28, 2023
1 parent 126cbc3 commit 1fc2872
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions salt/fileserver/s3fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@
More info here:
https://docs.aws.amazon.com/cli/latest/topic/s3-config.html
.. note:: This fileserver back-end will by default sync all buckets on every
fileserver update.
If you want files to be only populated in the cache when requested, you can
disable this in the master config:
.. code-block:: yaml
s3.s3_sync_on_update: False
"""


Expand All @@ -94,9 +104,6 @@

log = logging.getLogger(__name__)

S3_CACHE_EXPIRE = 30 # cache for 30 seconds
S3_SYNC_ON_UPDATE = True # sync cache on update rather than jit


def envs():
"""
Expand All @@ -116,7 +123,8 @@ def update():

metadata = _init()

if S3_SYNC_ON_UPDATE:
# sync cache on update rather than jit
if __opts__.get("s3.s3_sync_on_update", True):
# sync the buckets to the local cache
log.info("Syncing local cache from S3...")
for saltenv, env_meta in metadata.items():
Expand Down Expand Up @@ -343,7 +351,7 @@ def _init():
specified and cache the data to disk.
"""
cache_file = _get_buckets_cache_filename()
exp = time.time() - S3_CACHE_EXPIRE
exp = time.time() - __opts__.get("s3.s3_cache_expire", 30)

# check mtime of the buckets files cache
metadata = None
Expand Down

0 comments on commit 1fc2872

Please sign in to comment.