aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKonstantin Ryabitsev <konstantin@linuxfoundation.org>2018-08-15 17:31:33 -0400
committerKonstantin Ryabitsev <konstantin@linuxfoundation.org>2018-08-15 17:31:33 -0400
commit666205dc7d0f6671495e1cbeb5eafdf252f0a392 (patch)
tree8efa0c4f3c85db95fa96fe3981b19f2579174e83
parent636e3735aa36cde4ac18e9d88e738b627a3c8663 (diff)
downloadgrokmirror-666205dc7d0f6671495e1cbeb5eafdf252f0a392.tar.gz
Warn when we find grandchild repos
Having grandchild repos is a recipe for repo corruption, so warn when we find them. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rwxr-xr-xgrokmirror/fsck.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/grokmirror/fsck.py b/grokmirror/fsck.py
index 57c305a..e0bb65a 100755
--- a/grokmirror/fsck.py
+++ b/grokmirror/fsck.py
@@ -97,6 +97,12 @@ def run_git_repack(fullpath, config, level=1):
gitdir = '/' + os.path.relpath(fullpath, config['toplevel']).lstrip('/')
if grokmirror.is_alt_repo(config['toplevel'], gitdir):
# we are a "mother repo"
+ # are we using alternates ourselves? Multiple levels of alternates are
+ # a bad idea in general due high possibility of corruption.
+ if os.path.exists(os.path.join(fullpath, 'objects', 'info', 'alternates')):
+ logger.warning('warning : has alternates and is used by others for alternates')
+ logger.warning(' : this can cause grandchild corruption')
+ repack_flags.append('-l')
repack_flags.append('-k')
if level > 1:
repack_flags.append('-a')
@@ -148,6 +154,10 @@ def run_git_repack(fullpath, config, level=1):
# only repack refs on full repacks
if level < 2:
+ # do we still have loose objects after repacking?
+ obj_info = get_repo_obj_info(fullpath)
+ if obj_info['count'] != '0':
+ return run_git_prune(fullpath, config)
return repack_ok
# repacking refs requires a separate command, so run it now
@@ -202,6 +212,8 @@ def run_git_fsck(fullpath, config, conn_only=False):
debug = []
warn = []
for line in output.split('\n') + error.split('\n'):
+ if not len(line.strip()):
+ continue
ignored = False
for estring in config['ignore_errors']:
if line.find(estring) != -1:
@@ -518,7 +530,7 @@ def fsck_mirror(name, config, verbose=False, force=False, repack_only=False,
run.close()
em.stop()
- logger.info('Checked %s repos in %0.2fs', total_checked, total_elapsed)
+ logger.info('Processed %s repos in %0.2fs', total_checked, total_elapsed)
with open(config['statusfile'], 'wb') as stfh:
stfh.write(json.dumps(status, indent=2).encode('utf-8'))