Skip to content

Commit

Permalink
Add 64MB to memory-swap to work around PAASTA-12450
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Dudko committed Aug 26, 2017
1 parent 2e1d6e0 commit 1fda969
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
5 changes: 3 additions & 2 deletions paasta_tools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,11 @@ def get_mem_swap(self):
"""Gets the memory-swap value. This value is passed to the docker
container to ensure that the total memory limit (memory + swap) is the
same value as the 'mem' key in soa-configs. Note - this value *has* to
be >= to the mem key, so we always round up to the closest MB.
be >= to the mem key, so we always round up to the closest MB and add
additional 64MB for the docker executor (See PAASTA-12450).
"""
mem = self.get_mem()
mem_swap = int(math.ceil(mem))
mem_swap = int(math.ceil(mem + 64))
return "%sm" % mem_swap

def get_cpus(self):
Expand Down
10 changes: 5 additions & 5 deletions tests/test_chronos_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1084,7 +1084,7 @@ def test_format_chronos_job_dict(self):
'image': fake_docker_url,
'type': 'DOCKER',
'parameters': [
{'key': 'memory-swap', 'value': "1024m"},
{'key': 'memory-swap', 'value': "1088m"},
{"key": "cpu-period", "value": "%s" % int(fake_period)},
{"key": "cpu-quota", "value": "%s" % int(fake_cpu_quota)},
{"key": "label", "value": "paasta_service=test_service"},
Expand Down Expand Up @@ -1383,7 +1383,7 @@ def test_create_complete_config(self):
'image': "fake_registry/paasta-test-service-penguin",
'type': 'DOCKER',
'parameters': [
{'key': 'memory-swap', 'value': '1025m'},
{'key': 'memory-swap', 'value': '1089m'},
{"key": "cpu-period", "value": '100000'},
{"key": "cpu-quota", "value": '5500000'},
{"key": "label", "value": "paasta_service=test-service"},
Expand Down Expand Up @@ -1503,7 +1503,7 @@ def test_create_complete_config_desired_state_start(self):
'image': "fake_registry/fake_image",
'type': 'DOCKER',
'parameters': [
{'key': 'memory-swap', 'value': '1025m'},
{'key': 'memory-swap', 'value': '1089m'},
{"key": "cpu-period", "value": '100000'},
{"key": "cpu-quota", "value": '5500000'},
{"key": "label", "value": "paasta_service=test-service"},
Expand Down Expand Up @@ -1568,7 +1568,7 @@ def test_create_complete_config_desired_state_stop(self):
'image': "fake_registry/fake_image",
'type': 'DOCKER',
'parameters': [
{'key': 'memory-swap', 'value': '1025m'},
{'key': 'memory-swap', 'value': '1089m'},
{"key": "cpu-period", "value": '100000'},
{"key": "cpu-quota", "value": '5500000'},
{"key": "label", "value": "paasta_service=test-service"},
Expand Down Expand Up @@ -1649,7 +1649,7 @@ def test_create_complete_config_respects_extra_volumes(self):
'image': "fake_registry/fake_image",
'type': 'DOCKER',
'parameters': [
{'key': 'memory-swap', 'value': '1025m'},
{'key': 'memory-swap', 'value': '1089m'},
{"key": "cpu-period", "value": '100000'},
{"key": "cpu-quota", "value": '5500000'},
{"key": "label", "value": "paasta_service=test-service"},
Expand Down
8 changes: 4 additions & 4 deletions tests/test_marathon_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,7 @@ def test_format_marathon_app_dict(self):
},
],
'parameters': [
{'key': 'memory-swap', 'value': "%sm" % int(fake_mem)},
{'key': 'memory-swap', 'value': "%sm" % int(fake_mem + 64)},
{"key": "cpu-period", "value": "%s" % int(fake_period)},
{"key": "cpu-quota", "value": "%s" % int(fake_cpu_quota)},
{"key": "label", "value": "paasta_service=can_you_dig_it"},
Expand Down Expand Up @@ -2020,7 +2020,7 @@ def test_format_marathon_app_dict_no_smartstack():
'image': 'fake_docker_registry:443/abcdef',
'network': 'BRIDGE',
'parameters': [
{'key': 'memory-swap', 'value': '1024m'},
{'key': 'memory-swap', 'value': '1088m'},
{"key": "cpu-period", "value": '100000'},
{"key": "cpu-quota", "value": '250000'},
{"key": "label", "value": 'paasta_service=service'},
Expand Down Expand Up @@ -2091,7 +2091,7 @@ def test_format_marathon_app_dict_with_smartstack():
'image': 'fake_docker_registry:443/abcdef',
'network': 'BRIDGE',
'parameters': [
{'key': 'memory-swap', 'value': '1024m'},
{'key': 'memory-swap', 'value': '1088m'},
{"key": "cpu-period", "value": '100000'},
{"key": "cpu-quota", "value": '250000'},
{"key": "label", "value": 'paasta_service=service'},
Expand Down Expand Up @@ -2229,7 +2229,7 @@ def test_format_marathon_app_dict_utilizes_extra_volumes():
'image': 'fake_docker_registry:443/abcdef',
'network': 'BRIDGE',
'parameters': [
{'key': 'memory-swap', 'value': '1024m'},
{'key': 'memory-swap', 'value': '1088m'},
{"key": "cpu-period", "value": '100000'},
{"key": "cpu-quota", "value": '250000'},
{"key": "label", "value": 'paasta_service=service'},
Expand Down
8 changes: 4 additions & 4 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,7 @@ def test_format_docker_parameters_default(self):
branch_dict={},
)
assert fake_conf.format_docker_parameters() == [
{"key": "memory-swap", "value": '1024m'},
{"key": "memory-swap", "value": '1088m'},
{"key": "cpu-period", "value": "100000"},
{"key": "cpu-quota", "value": "1000000"},
{"key": "label", "value": "paasta_service=fake_name"},
Expand All @@ -930,7 +930,7 @@ def test_format_docker_parameters_non_default(self):
branch_dict={},
)
assert fake_conf.format_docker_parameters() == [
{"key": "memory-swap", "value": '1024m'},
{"key": "memory-swap", "value": '1088m'},
{"key": "cpu-period", "value": "200000"},
{"key": "cpu-quota", "value": "600000"},
{"key": "label", "value": "paasta_service=fake_name"},
Expand Down Expand Up @@ -961,7 +961,7 @@ def test_get_mem_swap_int(self):
},
branch_dict={},
)
assert fake_conf.get_mem_swap() == "50m"
assert fake_conf.get_mem_swap() == "114m"

def test_get_mem_swap_float_rounds_up(self):
fake_conf = utils.InstanceConfig(
Expand All @@ -973,7 +973,7 @@ def test_get_mem_swap_float_rounds_up(self):
},
branch_dict={},
)
assert fake_conf.get_mem_swap() == "51m"
assert fake_conf.get_mem_swap() == "115m"

def test_get_disk_in_config(self):
fake_conf = utils.InstanceConfig(
Expand Down

0 comments on commit 1fda969

Please sign in to comment.