mirror of
https://github.com/facebook/sapling.git
synced 2024-10-09 08:18:15 +03:00
infinitepush: make max bundle size configurable
Summary: Add a server-side config option `infinitepush.maxbundlesize` to control the maximum bundle size (currently 100MB). Add a test that shows bad behaviour when pushing backups that exceed this size. Differential Revision: D7498323 fbshipit-source-id: 640478e7a58cb3c39408fe2a24d8d581f14d891c
This commit is contained in:
parent
ac52e4a6fb
commit
bf2d6f85e3
@ -82,6 +82,9 @@
|
||||
# bundle for storage. Defaults to False.
|
||||
storeallparts = True
|
||||
|
||||
# Server-side option. Maximum acceptable bundle size in megabytes.
|
||||
maxbundlesize = 500
|
||||
|
||||
[remotenames]
|
||||
# Client-side option
|
||||
# This option should be set only if remotenames extension is enabled.
|
||||
@ -1318,10 +1321,13 @@ def storebundle(op, params, bundlefile):
|
||||
bundledata = f.read()
|
||||
with logservicecall(log, 'bundlestore',
|
||||
bundlesize=len(bundledata)):
|
||||
bundlesizelimit = 100 * 1024 * 1024 # 100 MB
|
||||
if len(bundledata) > bundlesizelimit:
|
||||
bundlesizelimitmb = op.repo.ui.configint('infinitepush',
|
||||
'maxbundlesize',
|
||||
100)
|
||||
if len(bundledata) > bundlesizelimitmb * 1024 * 1024:
|
||||
error_msg = ('bundle is too big: %d bytes. ' +
|
||||
'max allowed size is 100 MB')
|
||||
'max allowed size is %s MB'
|
||||
% bundlesizelimitmb)
|
||||
raise error.Abort(error_msg % (len(bundledata),))
|
||||
key = store.write(bundledata)
|
||||
|
||||
|
@ -602,3 +602,23 @@ Check if ssh batch mode enables only for background backup and not for foregroun
|
||||
$ waitbgbackup
|
||||
$ cat $TESTTMP/logs/test/* | debugsshcall
|
||||
running .* ".*/dummyssh" -bgssh 'user@dummy' 'hg -R repo serve --stdio' (re)
|
||||
|
||||
Fail to push a backup by setting the server maxbundlesize very low
|
||||
$ cp ../repo/.hg/hgrc $TESTTMP/server-hgrc.bak
|
||||
$ cat >> ../repo/.hg/hgrc << EOF
|
||||
> [infinitepush]
|
||||
> maxbundlesize = 0
|
||||
> EOF
|
||||
$ mkcommit toobig
|
||||
$ hg pushbackup
|
||||
starting backup .* (re)
|
||||
searching for changes
|
||||
remote: pushing 1 commit:
|
||||
remote: 034e9a5a003f toobig
|
||||
finished in \d+\.(\d+)? seconds (re)
|
||||
$ hg isbackedup -r .
|
||||
034e9a5a003f9f7dd44ab4b35187e833d0aad5c3 backed up
|
||||
$ scratchnodes | grep 034e9a5a003f9f7dd44ab4b35187e833d0aad5c3
|
||||
[1]
|
||||
|
||||
$ mv $TESTTMP/server-hgrc.bak ../repo/.hg/hgrc
|
||||
|
Loading…
Reference in New Issue
Block a user