diff options
author | Andy Doan <andy.doan@linaro.org> | 2016-04-06 10:28:24 -0500 |
---|---|---|
committer | Andy Doan <andy.doan@linaro.org> | 2016-04-06 10:28:24 -0500 |
commit | 4541f54919c1e242af2fb7018b76f0ddb955afe4 (patch) | |
tree | 1d186d6ea709041138a08243455fd31b4c9aaebf | |
parent | 36bf774bfadf0822491a841d8f0b396ed0bde8ed (diff) |
discard giant patches
We occasionally see giant patches come in, normally from libvirt
releases such as:
http://libvirt.org/git/?p=libvirt.git;a=commit;h=0086221cb377c7a1c2df58b8ee5eb8223f989765
Patchwork looks at patches line by line, and this consumes tons of
memory and runs for hours blocking everything. This detects giant
patches and safely discards them.
Change-Id: I2403941c708c0923bbe143e783f5869da88f880d
-rw-r--r-- | gitrepo.py | 3 | ||||
-rwxr-xr-x | update_commited_patches.py | 5 |
2 files changed, 7 insertions, 1 deletions
@@ -128,4 +128,7 @@ class Repo(object): # the patchwork parser code operates character by character so we must # convert to unicode so it can be handled properly patch = patch.decode('utf-8', errors='replace') + # Don't try and process >5Mb patches, they flood the server + if len(patch) > 5000000: + raise MemoryError('patch too large to process: %d' % len(patch)) return parse_patch(patch)[0] diff --git a/update_commited_patches.py b/update_commited_patches.py index 633eccf..a74358a 100755 --- a/update_commited_patches.py +++ b/update_commited_patches.py @@ -58,7 +58,10 @@ def _update_project(repo_dir, project, commits, dryrun): for commit in commits: log.debug('check commit: %s', commit.id) - _update_commit(project, repo, commit, dryrun) + try: + _update_commit(project, repo, commit, dryrun) + except MemoryError as e: + log.error('Unable to process commit(%s): %s', commit.id, e) if __name__ == '__main__': |