From c3f815a6f6fdf5d7b75cdc3ae524cf6aaebfff96 Mon Sep 17 00:00:00 2001 From: Aditya Marella Date: Mon, 12 Sep 2016 13:15:31 -0700 Subject: [PATCH] Docker module: add support for OomScoreAdj * docker-py param name oom_score_adj * translates to OomScoreAdj in the docker remote API * setting version_added to "2.2" --- lib/ansible/modules/cloud/docker/docker_container.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/ansible/modules/cloud/docker/docker_container.py b/lib/ansible/modules/cloud/docker/docker_container.py index b5e8313af8..1768f9629b 100644 --- a/lib/ansible/modules/cloud/docker/docker_container.py +++ b/lib/ansible/modules/cloud/docker/docker_container.py @@ -276,6 +276,12 @@ options: - Whether or not to disable OOM Killer for the container. default: false required: false + oom_score_adj: + description: + - An integer value containing the score given to the container in order to tune OOM killer preferences. + default: 0 + required: false + version_added: "2.2" paused: description: - Use with the started state to pause running processes inside the container. @@ -713,6 +719,7 @@ class TaskParameters(DockerBaseClass): self.network_mode = None self.networks = None self.oom_killer = None + self.oom_score_adj = None self.paused = None self.pid_mode = None self.privileged = None @@ -909,6 +916,7 @@ class TaskParameters(DockerBaseClass): mem_limit='memory', memswap_limit='memory_swap', mem_swappiness='memory_swappiness', + oom_score_adj='oom_score_adj', shm_size='shm_size', group_add='groups', devices='devices', @@ -1218,6 +1226,7 @@ class Container(DockerBaseClass): memory_swappiness=host_config.get('MemorySwappiness'), network_mode=host_config.get('NetworkMode'), oom_killer=host_config.get('OomKillDisable'), + oom_score_adj=host_config.get('OomScoreAdj'), pid_mode=host_config.get('PidMode'), privileged=host_config.get('Privileged'), expected_ports=host_config.get('PortBindings'), @@ -1329,6 +1338,7 @@ class Container(DockerBaseClass): memory=host_config.get('Memory'), memory_reservation=host_config.get('MemoryReservation'), memory_swap=host_config.get('MemorySwap'), + oom_score_adj=host_config.get('OomScoreAdj'), ) differences = [] @@ -1917,6 +1927,7 @@ def main(): network_mode=dict(type='str'), networks=dict(type='list'), oom_killer=dict(type='bool'), + oom_score_adj=dict(type='int'), paused=dict(type='bool', default=False), pid_mode=dict(type='str'), privileged=dict(type='bool', default=False),