Skip to content

Commit

Permalink
Added support for cgroup parent
Browse files Browse the repository at this point in the history
Clean up cgroup_parent usage
  • Loading branch information
mohitsoni authored and shin- committed Aug 24, 2015
1 parent 4008cbc commit 3caaa00
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
5 changes: 4 additions & 1 deletion docker/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ def create_host_config(
restart_policy=None, cap_add=None, cap_drop=None, devices=None,
extra_hosts=None, read_only=None, pid_mode=None, ipc_mode=None,
security_opt=None, ulimits=None, log_config=None, mem_limit=None,
memswap_limit=None
memswap_limit=None, cgroup_parent=None
):
host_config = {}

Expand Down Expand Up @@ -500,6 +500,9 @@ def create_host_config(
if lxc_conf is not None:
host_config['LxcConf'] = lxc_conf

if cgroup_parent is not None:
host_config['CgroupParent'] = cgroup_parent

if ulimits is not None:
if not isinstance(ulimits, list):
raise errors.DockerException(
Expand Down
18 changes: 18 additions & 0 deletions tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,24 @@ def test_create_container_with_cpuset(self):
self.assertEqual(args[1]['headers'],
{'Content-Type': 'application/json'})

def test_create_container_with_cgroup_parent(self):
try:
self.client.create_container(
'busybox', 'ls', host_config=create_host_config(
cgroup_parent='test'
)
)
except Exception as e:
self.fail('Command should not raise exception: {0}'.format(e))

args = fake_request.call_args
self.assertEqual(args[0][0],
url_prefix + 'containers/create')
data = json.loads(args[1]['data'])
self.assertIn('HostConfig', data)
self.assertIn('CgroupParent', data['HostConfig'])
self.assertEqual(data['HostConfig']['CgroupParent'], 'test')

def test_create_container_with_working_dir(self):
try:
self.client.create_container('busybox', 'ls',
Expand Down

0 comments on commit 3caaa00

Please sign in to comment.