Skip to content

Commit 0750457

Browse files
committed
Merge remote-tracking branch 'origin/master' into edge
2 parents 9462073 + 2f1a9db commit 0750457

File tree

8 files changed

+70
-2
lines changed

8 files changed

+70
-2
lines changed

mig/install/MiGserver-template.conf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,18 @@ gdp_email_notify = __GDP_EMAIL_NOTIFY__
196196
# NOTE: the sftpsubsys service is advertized as just sftp to fit the protocol.
197197
storage_protocols = __STORAGE_PROTOCOLS__
198198

199+
# Optional limit which instructs the web backends to deliver at most N bytes of
200+
# output to the users in order to avoid excessive memory use when serving files
201+
# which are subject to in-memory buffering. Defaults to a value of -1 which
202+
# disables the limit completely while 0 or any positive integer is intepreted
203+
# as a total number of bytes to allow serving in a single request.
204+
#
205+
# For now the limit is only enforced on cat.py, which is used implicitly for
206+
# certain downloads depending on site settings as well as for explicit client
207+
# requests e.g. xmlrpc requests or user scripts. The limit may or may not go
208+
# away in the future if better streaming of such requests can be made.
209+
wwwserve_max_bytes = __WWWSERVE_MAX_BYTES__
210+
199211
# Optional extra service interfaces with common structure
200212
# * user_X_address is the host address to listen on
201213
# * user_X_port is the host port to listen on

mig/install/generateconfs.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ def main(argv, _generate_confs=generate_confs, _print=print):
247247
'seafile_quota',
248248
'quota_user_limit',
249249
'quota_vgrid_limit',
250+
'wwwserve_max_bytes',
250251
]
251252
bool_names = [
252253
'auto_add_cert_user',

mig/shared/configuration.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@ def fix_missing(config_file, verbose=True):
181181
'mig_system_storage': '~/state/mig_system_storage',
182182
'mig_system_run': '~/state/mig_system_run/',
183183
'wwwpublic': '~/state/wwwpublic/',
184-
'wwwserve_max_bytes': -1,
185184
'vm_home': '~/state/vm_home',
186185
'server_cert': '~/certs/cert.pem',
187186
'server_key': '~/certs/key.pem',
@@ -1626,6 +1625,10 @@ def reload_config(self, verbose, skip_log=False, disable_auth_log=False,
16261625
else:
16271626
self.storage_protocols = prio_storage_protos
16281627

1628+
if config.has_option('GLOBAL', 'wwwserve_max_bytes'):
1629+
self.wwwserve_max_bytes = config.getint(
1630+
'GLOBAL', 'wwwserve_max_bytes')
1631+
16291632
if config.has_option('SITE', 'enable_jupyter'):
16301633
self.site_enable_jupyter = config.getboolean(
16311634
'SITE', 'enable_jupyter')

mig/shared/install.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,7 @@ def generate_confs(
505505
ca_smtp='localhost',
506506
datasafety_link='',
507507
datasafety_text='',
508+
wwwserve_max_bytes=-1,
508509
_getpwnam=pwd.getpwnam,
509510
_prepare=None,
510511
_writefiles=None,
@@ -821,6 +822,7 @@ def _generate_confs_prepare(
821822
ca_smtp,
822823
datasafety_link,
823824
datasafety_text,
825+
wwwserve_max_bytes,
824826
):
825827
"""Prepate conf generator run"""
826828
user_dict = {}
@@ -1073,6 +1075,7 @@ def _generate_confs_prepare(
10731075
user_dict['__CA_SMTP__'] = ca_smtp
10741076
user_dict['__DATASAFETY_LINK__'] = datasafety_link
10751077
user_dict['__DATASAFETY_TEXT__'] = datasafety_text
1078+
user_dict['__WWWSERVE_MAX_BYTES__'] = "%d" % (wwwserve_max_bytes)
10761079

10771080
user_dict['__MIG_USER__'] = "%s" % (options['user_uname'])
10781081
user_dict['__MIG_GROUP__'] = "%s" % (options['user_group'])

tests/data/MiGserver--storage_protocols.conf renamed to tests/data/MiGserver--customised.conf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,18 @@ gdp_email_notify = False
196196
# NOTE: the sftpsubsys service is advertized as just sftp to fit the protocol.
197197
storage_protocols = sftp
198198

199+
# Optional limit which instructs the web backends to deliver at most N bytes of
200+
# output to the users in order to avoid excessive memory use when serving files
201+
# which are subject to in-memory buffering. Defaults to a value of -1 which
202+
# disables the limit completely while 0 or any positive integer is intepreted
203+
# as a total number of bytes to allow serving in a single request.
204+
#
205+
# For now the limit is only enforced on cat.py, which is used implicitly for
206+
# certain downloads depending on site settings as well as for explicit client
207+
# requests e.g. xmlrpc requests or user scripts. The limit may or may not go
208+
# away in the future if better streaming of such requests can be made.
209+
wwwserve_max_bytes = 43211234
210+
199211
# Optional extra service interfaces with common structure
200212
# * user_X_address is the host address to listen on
201213
# * user_X_port is the host port to listen on

tests/fixture/confs-stdlocal/MiGserver.conf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,18 @@ gdp_email_notify = False
196196
# NOTE: the sftpsubsys service is advertized as just sftp to fit the protocol.
197197
storage_protocols = AUTO
198198

199+
# Optional limit which instructs the web backends to deliver at most N bytes of
200+
# output to the users in order to avoid excessive memory use when serving files
201+
# which are subject to in-memory buffering. Defaults to a value of -1 which
202+
# disables the limit completely while 0 or any positive integer is intepreted
203+
# as a total number of bytes to allow serving in a single request.
204+
#
205+
# For now the limit is only enforced on cat.py, which is used implicitly for
206+
# certain downloads depending on site settings as well as for explicit client
207+
# requests e.g. xmlrpc requests or user scripts. The limit may or may not go
208+
# away in the future if better streaming of such requests can be made.
209+
wwwserve_max_bytes = -1
210+
199211
# Optional extra service interfaces with common structure
200212
# * user_X_address is the host address to listen on
201213
# * user_X_port is the host port to listen on

tests/test_mig_install_generateconfs.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,22 @@ def test_option_storage_protocols(self):
9999
self.assertIn('storage_protocols', settings)
100100
self.assertEqual(settings['storage_protocols'], 'proto1 proto2 proto3')
101101

102+
def test_option_wwwserve_max_bytes(self):
103+
expected_generated_dir = cleanpath('confs-stdlocal', self,
104+
ensure_dir=True)
105+
with open(os.path.join(expected_generated_dir, "instructions.txt"),
106+
"w"):
107+
pass
108+
fake_generate_confs = create_fake_generate_confs(
109+
dict(destination_dir=expected_generated_dir))
110+
test_arguments = ['--wwwserve_max_bytes', '43211234']
111+
112+
exit_code = main(
113+
test_arguments, _generate_confs=fake_generate_confs, _print=noop)
114+
settings = fake_generate_confs.settings
115+
self.assertIn('wwwserve_max_bytes', settings)
116+
self.assertEqual(settings['wwwserve_max_bytes'], 43211234)
117+
102118

103119
if __name__ == '__main__':
104120
testmain()

tests/test_mig_shared_configuration.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class MigSharedConfiguration(MigTestCase):
4949

5050
def test_argument_storage_protocols(self):
5151
test_conf_file = os.path.join(
52-
TEST_DATA_DIR, 'MiGserver--storage_protocols.conf')
52+
TEST_DATA_DIR, 'MiGserver--customised.conf')
5353

5454
configuration = Configuration(
5555
test_conf_file, skip_log=True, disable_auth_log=True)
@@ -60,6 +60,15 @@ def test_argument_storage_protocols(self):
6060
#self.assertEqual(configuration.storage_protocols, ['sftp'])
6161
self.assertEqual(configuration.storage_protocols, [])
6262

63+
def test_argument_wwwserve_max_bytes(self):
64+
test_conf_file = os.path.join(
65+
TEST_DATA_DIR, 'MiGserver--customised.conf')
66+
67+
configuration = Configuration(
68+
test_conf_file, skip_log=True, disable_auth_log=True)
69+
70+
self.assertEqual(configuration.wwwserve_max_bytes, 43211234)
71+
6372
@unittest.skipIf(PY2, "Python 3 only")
6473
def test_default_object(self):
6574
expected_values = fixturefile(

0 commit comments

Comments
 (0)