Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3006.x] Fix env #65017

Merged
merged 38 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
12f9260
wip fix env
cmcmarrow Aug 21, 2023
3dd4f64
clear cache after upgrade or downgrade
cmcmarrow Aug 22, 2023
1a21f97
Merge branch '3006.x' into fix_env
cmcmarrow Aug 22, 2023
b8a5590
clean up clean old remotes
cmcmarrow Aug 23, 2023
720edbf
place fetch request file on fetch
cmcmarrow Aug 23, 2023
9366833
fetch_request_check
cmcmarrow Aug 23, 2023
d8061b4
fire fetch request
cmcmarrow Aug 23, 2023
0d27aa0
update some unit tests
cmcmarrow Aug 24, 2023
ea6bff7
Merge branch '3006.x' into fix_env
cmcmarrow Aug 24, 2023
73397cd
fix test minion start
cmcmarrow Aug 24, 2023
35a931c
only clear cache in gtfs dirs
cmcmarrow Aug 25, 2023
61da06e
add cache tests
cmcmarrow Aug 25, 2023
209bd47
Merge branch '3006.x' into fix_env
cmcmarrow Aug 25, 2023
03dae69
doc and exception update
cmcmarrow Aug 25, 2023
6048596
linkdir -> _linkdir
cmcmarrow Jul 24, 2023
b5437ce
bad copy
cmcmarrow Aug 26, 2023
fea95bb
fix pygit2
cmcmarrow Aug 27, 2023
0e675a2
move fetch_request to try else
cmcmarrow Aug 27, 2023
8cd578f
tests
cmcmarrow Aug 28, 2023
ed34a40
Merge branch '3006.x' into fix_env
cmcmarrow Aug 28, 2023
0b1d2b0
pillarenv dynamic
cmcmarrow Aug 28, 2023
5a5adfe
fix some tests
cmcmarrow Aug 28, 2023
e2d43b0
m
cmcmarrow Aug 29, 2023
da149d7
fix gtfs ssl
cmcmarrow Aug 30, 2023
0aaf09f
Merge branch '3006.x' into fix_env
cmcmarrow Aug 30, 2023
e9e8832
fire up gitfs
cmcmarrow Aug 31, 2023
6d76add
test __env__ cache
cmcmarrow Sep 1, 2023
d45fcac
fix file name typo
cmcmarrow Sep 1, 2023
e68115f
fetch_on_fail
cmcmarrow Sep 1, 2023
f33ff21
winrepo tests
cmcmarrow Sep 1, 2023
993a3b1
Merge branch '3006.x' into fix_env
cmcmarrow Sep 1, 2023
3271614
multi tests
cmcmarrow Sep 1, 2023
71d440b
fetch_request & clear_old_remote tests
cmcmarrow Sep 1, 2023
36a78d2
revert ssl
cmcmarrow Sep 4, 2023
efaa2cd
Add Murphy tests
cmcmarrow Sep 5, 2023
534e588
clean up murphy
cmcmarrow Sep 5, 2023
254c2ec
fix name
cmcmarrow Sep 5, 2023
aba580f
Merge branch '3006.x' into fix_env
cmcmarrow Sep 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/65002.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix __env__ and improve cache cleaning see more info at pull #65017.
32 changes: 32 additions & 0 deletions salt/utils/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import logging
import os
import re
import shutil
import time

import salt.config
Expand All @@ -15,6 +16,8 @@
import salt.utils.dictupdate
import salt.utils.files
import salt.utils.msgpack
import salt.utils.path
import salt.version
from salt.utils.zeromq import zmq

log = logging.getLogger(__name__)
Expand Down Expand Up @@ -345,3 +348,32 @@ def context_cache_wrap(*args, **kwargs):
return func(*args, **kwargs)

return context_cache_wrap


def verify_cache_version(cache_path):
"""
Check that the cached version matches the Salt version.
If the cached version does not match the Salt version, wipe the cache.

:return: ``True`` if cache version matches, otherwise ``False``
"""
if not os.path.isdir(cache_path):
os.makedirs(cache_path)
Ch3LL marked this conversation as resolved.
Show resolved Hide resolved
with salt.utils.files.fopen(
salt.utils.path.join(cache_path, "cache_version"), "a+"
) as file:
file.seek(0)
data = "\n".join(file.readlines())
if data != salt.version.__version__:
log.warning(f"Cache version mismatch clearing: {repr(cache_path)}")
file.truncate(0)
file.write(salt.version.__version__)
for item in os.listdir(cache_path):
if item != "cache_version":
item_path = salt.utils.path.join(cache_path, item)
if os.path.isfile(item_path):
os.remove(item_path)
else:
shutil.rmtree(item_path)
return False
return True
Loading
Loading