Skip to content
This repository has been archived by the owner on Aug 3, 2020. It is now read-only.

Commit

Permalink
allow shared/slave flags for docker volumes
Browse files Browse the repository at this point in the history
  • Loading branch information
sidharthamani committed Jun 2, 2016
1 parent d4a5088 commit 65d681c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
7 changes: 5 additions & 2 deletions cattle/plugins/docker/compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,8 +699,11 @@ def _setup_volumes(self, create_config, instance, start_config, client):
if len(parts) == 1:
volumes_map[parts[0]] = {}
else:
read_only = len(parts) == 3 and parts[2] == 'ro'
bind = {'bind': parts[1], 'ro': read_only}
if len(parts) == 3:
mode = parts[2]
else:
mode = 'rw'
bind = {'bind': parts[1], 'mode': mode}
binds_map[parts[0]] = bind
create_config['volumes'] = volumes_map
start_config['binds'] = binds_map
Expand Down
2 changes: 1 addition & 1 deletion tests/docker/instance_activate_volumes
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"imageUuid": "docker:ibuildthecloud/helloworld",
"command": "sleep 5",
"publishAllPorts": true,
"dataVolumes": ["/proc:/host/proc", "/sys:/host/sys:ro", "/random"],
"dataVolumes": ["/proc:/host/proc", "/sys:/host/sys:ro", "/random", "/slave_test:/slave_test:Z"],
"startOnCreate": true
}
},
Expand Down
8 changes: 5 additions & 3 deletions tests/test_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1191,18 +1191,20 @@ def post(req, resp):
assert inspect['Volumes']['/volumes_from_path_by_uuid'] is not None
assert inspect['Volumes']['/volumes_from_path_by_id'] is not None

assert len(inspect['Volumes']) == 5
assert len(inspect['Volumes']) == 6

assert inspect['VolumesRW'] == {
'/host/proc': True,
'/host/sys': False,
'/random': True,
'/volumes_from_path_by_uuid': True,
'/volumes_from_path_by_id': True,

'/slave_test': True,
}

assert set(['/sys:/host/sys:ro', '/proc:/host/proc:rw']) == set(
assert set(['/sys:/host/sys:ro',
'/proc:/host/proc:rw',
'/slave_test:/slave_test:Z']) == set(
inspect['HostConfig']['Binds'])

instance_activate_common_validation(resp)
Expand Down

0 comments on commit 65d681c

Please sign in to comment.