mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Fix for when dulwich-managed repos get in bad state
This commit logs an error and deletes the master cachedir if the repo cachedir gets into a bad state.
This commit is contained in:
parent
bccd82aacf
commit
d2354e6261
@ -590,7 +590,10 @@ def init():
|
||||
|
||||
if repo is not None:
|
||||
remote_conf.update({
|
||||
'repo': repo, 'uri': repo_uri, 'hash': repo_hash
|
||||
'repo': repo,
|
||||
'uri': repo_uri,
|
||||
'hash': repo_hash,
|
||||
'cachedir': rp_
|
||||
})
|
||||
repos.append(remote_conf)
|
||||
|
||||
@ -784,7 +787,25 @@ def update():
|
||||
origin, thin_packs=True
|
||||
)
|
||||
refs_pre = repo.get_refs()
|
||||
refs_post = client.fetch(path, repo)
|
||||
try:
|
||||
refs_post = client.fetch(path, repo)
|
||||
except KeyError:
|
||||
log.critical(
|
||||
'Local repository cachedir {0!r} (corresponding '
|
||||
'remote: {1}) has been corrupted. Salt will now '
|
||||
'attempt to remove the local checkout to allow it to '
|
||||
'be re-initialized in the next fileserver cache '
|
||||
'update.'
|
||||
.format(repo_conf['cachedir'], repo_conf['uri'])
|
||||
)
|
||||
try:
|
||||
salt.utils.rm_rf(repo_conf['cachedir'])
|
||||
except OSError as exc:
|
||||
log.critical(
|
||||
'Unable to remove {0!r}: {1}'
|
||||
.format(repo_conf['cachedir'], exc)
|
||||
)
|
||||
continue
|
||||
if refs_post is None:
|
||||
# Empty repository
|
||||
log.warning(
|
||||
|
Loading…
Reference in New Issue
Block a user