mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Add support for removing corrupted cache entries in tools vm sync-cache
This commit is contained in:
parent
afb229431c
commit
bc3d04d207
1 changed files with 13 additions and 3 deletions
16
tools/vm.py
16
tools/vm.py
|
@ -592,9 +592,19 @@ def sync_cache(
|
|||
cached_instances = {}
|
||||
if STATE_DIR.exists():
|
||||
for state_path in STATE_DIR.iterdir():
|
||||
instance_id_path = state_path / "instance-id"
|
||||
if instance_id_path.exists():
|
||||
instance_id = instance_id_path.read_text()
|
||||
try:
|
||||
instance_id = (state_path / "instance-id").read_text()
|
||||
except FileNotFoundError:
|
||||
if not delete:
|
||||
log.info(
|
||||
f"Would remove {state_path.name} (No valid ID) from cache at {state_path}"
|
||||
)
|
||||
else:
|
||||
shutil.rmtree(state_path)
|
||||
log.info(
|
||||
f"REMOVED {state_path.name} (No valid ID) from cache at {state_path}"
|
||||
)
|
||||
else:
|
||||
cached_instances[instance_id] = state_path.name
|
||||
|
||||
# Find what instances we are missing in our cached states
|
||||
|
|
Loading…
Add table
Reference in a new issue