Browse Source

Fix mem_limit and memswap_limit regression

Signed-off-by: Aanand Prasad <[email protected]>
Aanand Prasad 10 years ago
parent
commit
982a845635
2 changed files with 6 additions and 2 deletions
  1. 4 0
      compose/service.py
  2. 2 2
      tests/unit/service_test.py

+ 4 - 0
compose/service.py

@@ -42,6 +42,8 @@ DOCKER_START_KEYS = [
     'net',
     'log_driver',
     'log_opt',
+    'mem_limit',
+    'memswap_limit',
     'pid',
     'privileged',
     'restart',
@@ -684,6 +686,8 @@ class Service(object):
             restart_policy=restart,
             cap_add=cap_add,
             cap_drop=cap_drop,
+            mem_limit=options.get('mem_limit'),
+            memswap_limit=options.get('memswap_limit'),
             log_config=log_config,
             extra_hosts=extra_hosts,
             read_only=read_only,

+ 2 - 2
tests/unit/service_test.py

@@ -173,8 +173,8 @@ class ServiceTest(unittest.TestCase):
         service = Service(name='foo', image='foo', hostname='name', client=self.mock_client, mem_limit=1000000000, memswap_limit=2000000000)
         self.mock_client.containers.return_value = []
         opts = service._get_container_create_options({'some': 'overrides'}, 1)
-        self.assertEqual(opts['memswap_limit'], 2000000000)
-        self.assertEqual(opts['mem_limit'], 1000000000)
+        self.assertEqual(opts['host_config']['MemorySwap'], 2000000000)
+        self.assertEqual(opts['host_config']['Memory'], 1000000000)
 
     def test_log_opt(self):
         log_opt = {'address': 'tcp://192.168.0.42:123'}