From 0812b1c5d174d4ad2b82824c861b79011c6ece75 Mon Sep 17 00:00:00 2001 From: yuvipanda Date: Thu, 23 Aug 2018 07:12:07 -0400 Subject: [PATCH 1/3] Don't set a memory limit by default Users should set up their own memory limits after install. Better than a surprise when they try using more than 1G. --- tljh/configurer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tljh/configurer.py b/tljh/configurer.py index 29eb49f..0cc4694 100644 --- a/tljh/configurer.py +++ b/tljh/configurer.py @@ -28,7 +28,7 @@ default = { 'admin': [], }, 'limits': { - 'memory': '1G', + 'memory': None, 'cpu': None, }, 'http': { From cff22b5b5cb89d7782f2d3e787d2c7c85d2178d0 Mon Sep 17 00:00:00 2001 From: Tim Head Date: Mon, 15 Oct 2018 15:56:03 +0200 Subject: [PATCH 2/3] Add sentence to docs about default CPU and RAM limits --- docs/topic/tljh-config.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/topic/tljh-config.rst b/docs/topic/tljh-config.rst index 0570d63..4c62e17 100644 --- a/docs/topic/tljh-config.rst +++ b/docs/topic/tljh-config.rst @@ -81,7 +81,8 @@ User Server Limits * ``limits.memory`` Specifies the maximum memory that can be used by each - individual user. It can be specified as an absolute byte value. You can use + individual user. By default there is no memory limit. The limit can be + specified as an absolute byte value. You can use the suffixes K, M, G or T to mean Kilobyte, Megabyte, Gigabyte or Terabyte respectively. Setting it to ``None`` disables memory limits. @@ -95,6 +96,7 @@ User Server Limits handedly take down the machine accidentally by OOMing it. * ``limits.cpu`` A float representing the total CPU-cores each user can use. + By default there is no CPU limit. 1 represents one full CPU, 4 represents 4 full CPUs, 0.5 represents half of one CPU, etc. This value is ultimately converted to a percentage and rounded down to the nearest integer percentage, From c67f34daca4115b9f58b02cd6f023451cef62bfa Mon Sep 17 00:00:00 2001 From: Tim Head Date: Mon, 15 Oct 2018 16:03:31 +0200 Subject: [PATCH 3/3] Add tests for per user memory limit --- tests/test_configurer.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/test_configurer.py b/tests/test_configurer.py index df4b69f..59dd6ec 100644 --- a/tests/test_configurer.py +++ b/tests/test_configurer.py @@ -59,6 +59,22 @@ def apply_mock_config(overrides): return c +def test_default_memory_limit(): + """ + Test default per user memory limit + """ + c = apply_mock_config({}) + assert c.SystemdSpawner.mem_limit is None + + +def test_set_memory_limit(): + """ + Test setting per user memory limit + """ + c = apply_mock_config({'limits': {'memory': '42G'}}) + assert c.SystemdSpawner.mem_limit == '42G' + + def test_app_default(): """ Test default application with no config overrides.