Adds Cinder Volume Support to Swarm Bay Type

Previously, the swarm bay type did not support using a cinder
volume for docker.

Implements: blueprint swarm-cinder

Change-Id: I8acaf60caab52a5e5a234e4c5f89ce3dd155759c
This commit is contained in:
Daneyon Hansen 2015-11-13 21:49:33 +00:00
parent 9f95010246
commit 4a2c71c4c4
6 changed files with 98 additions and 2 deletions

View File

@ -571,6 +571,8 @@ class AtomicSwarmTemplateDefinition(BaseTemplateDefinition):
param_type=str) param_type=str)
self.add_parameter('server_flavor', self.add_parameter('server_flavor',
baymodel_attr='flavor_id') baymodel_attr='flavor_id')
self.add_parameter('docker_volume_size',
baymodel_attr='docker_volume_size')
self.add_parameter('external_network', self.add_parameter('external_network',
baymodel_attr='external_network_id', baymodel_attr='external_network_id',
required=True) required=True)

View File

@ -0,0 +1,25 @@
#!/bin/sh
. /etc/sysconfig/heat-params
DOCKER_DEV=/dev/disk/by-id/virtio-${DOCKER_VOLUME:0:20}
attempts=60
while [[ ! -b $DOCKER_DEV && $attempts != 0 ]]; do
echo "waiting for disk $DOCKER_DEV"
sleep 0.5
udevadm trigger
let attempts--
done
if ! [ -b $DOCKER_DEV ]; then
echo "ERROR: device $DOCKER_DEV does not exist" >&2
exit 1
fi
pvcreate $DOCKER_DEV
vgcreate docker $DOCKER_DEV
cat > /etc/sysconfig/docker-storage-setup <<EOF
VG=docker
EOF

View File

@ -6,6 +6,7 @@ write_files:
permissions: "0644" permissions: "0644"
content: | content: |
WAIT_HANDLE="$WAIT_HANDLE" WAIT_HANDLE="$WAIT_HANDLE"
DOCKER_VOLUME="$DOCKER_VOLUME"
HTTP_PROXY="$HTTP_PROXY" HTTP_PROXY="$HTTP_PROXY"
HTTPS_PROXY="$HTTPS_PROXY" HTTPS_PROXY="$HTTPS_PROXY"
NO_PROXY="$NO_PROXY" NO_PROXY="$NO_PROXY"

View File

@ -75,6 +75,13 @@ parameters:
description: how many swarm nodes to spawn description: how many swarm nodes to spawn
default: 1 default: 1
docker_volume_size:
type: number
description: >
size of a cinder volume to allocate to docker for container/image
storage
default: 25
fixed_network_cidr: fixed_network_cidr:
type: string type: string
description: network range for fixed ip network description: network range for fixed ip network
@ -192,6 +199,7 @@ resources:
template: {get_file: fragments/write-heat-params.yaml} template: {get_file: fragments/write-heat-params.yaml}
params: params:
"$WAIT_HANDLE": {get_resource: cloud_init_wait_handle} "$WAIT_HANDLE": {get_resource: cloud_init_wait_handle}
"$DOCKER_VOLUME": {get_resource: docker_volume}
"$HTTP_PROXY": {get_param: http_proxy} "$HTTP_PROXY": {get_param: http_proxy}
"$HTTPS_PROXY": {get_param: https_proxy} "$HTTPS_PROXY": {get_param: https_proxy}
"$NO_PROXY": {get_param: no_proxy} "$NO_PROXY": {get_param: no_proxy}
@ -306,6 +314,12 @@ resources:
group: ungrouped group: ungrouped
config: {get_file: fragments/disable-selinux.sh} config: {get_file: fragments/disable-selinux.sh}
configure_docker_storage:
type: OS::Heat::SoftwareConfig
properties:
group: ungrouped
config: {get_file: fragments/configure-docker-storage.sh}
add_proxy: add_proxy:
type: "OS::Heat::SoftwareConfig" type: "OS::Heat::SoftwareConfig"
properties: properties:
@ -320,6 +334,7 @@ resources:
- config: {get_resource: remove_docker_key} - config: {get_resource: remove_docker_key}
- config: {get_resource: write_heat_params} - config: {get_resource: write_heat_params}
- config: {get_resource: make_cert} - config: {get_resource: make_cert}
- config: {get_resource: configure_docker_storage}
- config: {get_resource: write_swarm_agent_failure_service} - config: {get_resource: write_swarm_agent_failure_service}
- config: {get_resource: write_swarm_manager_failure_service} - config: {get_resource: write_swarm_manager_failure_service}
- config: {get_resource: write_docker_service} - config: {get_resource: write_docker_service}
@ -387,6 +402,7 @@ resources:
ssh_key_name: {get_param: ssh_key_name} ssh_key_name: {get_param: ssh_key_name}
server_image: {get_param: server_image} server_image: {get_param: server_image}
server_flavor: {get_param: server_flavor} server_flavor: {get_param: server_flavor}
docker_volume_size: {get_param: docker_volume_size}
fixed_network_id: {get_resource: fixed_network} fixed_network_id: {get_resource: fixed_network}
fixed_subnet_id: {get_resource: fixed_subnet} fixed_subnet_id: {get_resource: fixed_subnet}
external_network: {get_param: external_network} external_network: {get_param: external_network}
@ -400,6 +416,24 @@ resources:
magnum_url: {get_param: magnum_url} magnum_url: {get_param: magnum_url}
tls_disabled: {get_param: tls_disabled} tls_disabled: {get_param: tls_disabled}
######################################################################
#
# docker storage. This allocates a cinder volume and attaches it
# to the master.
#
docker_volume:
type: OS::Cinder::Volume
properties:
size: {get_param: docker_volume_size}
docker_volume_attach:
type: OS::Cinder::VolumeAttachment
properties:
instance_uuid: {get_resource: swarm_master}
volume_id: {get_resource: docker_volume}
mountpoint: /dev/vdb
outputs: outputs:
api_address: api_address:

View File

@ -22,6 +22,12 @@ parameters:
description: name of ssh key to be provisioned on our server description: name of ssh key to be provisioned on our server
default: lars default: lars
docker_volume_size:
type: number
description: >
size of a cinder volume to allocate to docker for container/image
storage
external_network: external_network:
type: string type: string
description: uuid/name of a network to use for floating ip addresses description: uuid/name of a network to use for floating ip addresses
@ -127,6 +133,7 @@ resources:
template: {get_file: fragments/write-heat-params.yaml} template: {get_file: fragments/write-heat-params.yaml}
params: params:
"$WAIT_HANDLE": {get_resource: node_cloud_init_wait_handle} "$WAIT_HANDLE": {get_resource: node_cloud_init_wait_handle}
"$DOCKER_VOLUME": {get_resource: docker_volume}
"$HTTP_PROXY": {get_param: http_proxy} "$HTTP_PROXY": {get_param: http_proxy}
"$HTTPS_PROXY": {get_param: https_proxy} "$HTTPS_PROXY": {get_param: https_proxy}
"$NO_PROXY": {get_param: no_proxy} "$NO_PROXY": {get_param: no_proxy}
@ -155,6 +162,12 @@ resources:
group: ungrouped group: ungrouped
config: {get_file: fragments/make-cert.py} config: {get_file: fragments/make-cert.py}
configure_docker_storage:
type: OS::Heat::SoftwareConfig
properties:
group: ungrouped
config: {get_file: fragments/configure-docker-storage.sh}
write_docker_service: write_docker_service:
type: "OS::Heat::SoftwareConfig" type: "OS::Heat::SoftwareConfig"
properties: properties:
@ -229,6 +242,7 @@ resources:
- config: {get_resource: remove_docker_key} - config: {get_resource: remove_docker_key}
- config: {get_resource: write_heat_params} - config: {get_resource: write_heat_params}
- config: {get_resource: make_cert} - config: {get_resource: make_cert}
- config: {get_resource: configure_docker_storage}
- config: {get_resource: write_swarm_agent_failure_service} - config: {get_resource: write_swarm_agent_failure_service}
- config: {get_resource: write_swarm_agent_service} - config: {get_resource: write_swarm_agent_service}
- config: {get_resource: write_docker_service} - config: {get_resource: write_docker_service}
@ -272,6 +286,24 @@ resources:
port_id: port_id:
get_resource: swarm_node_eth0 get_resource: swarm_node_eth0
######################################################################
#
# docker storage. This allocates a cinder volume and attaches it
# to the node.
#
docker_volume:
type: OS::Cinder::Volume
properties:
size: {get_param: docker_volume_size}
docker_volume_attach:
type: OS::Cinder::VolumeAttachment
properties:
instance_uuid: {get_resource: swarm_node}
volume_id: {get_resource: docker_volume}
mountpoint: /dev/vdb
outputs: outputs:
swarm_node_ip: swarm_node_ip:

View File

@ -31,6 +31,7 @@ class TestBayConductorWithSwarm(base.TestCase):
'flavor_id': 'flavor_id', 'flavor_id': 'flavor_id',
'keypair_id': 'keypair_id', 'keypair_id': 'keypair_id',
'dns_nameserver': 'dns_nameserver', 'dns_nameserver': 'dns_nameserver',
'docker_volume_size': 20,
'external_network_id': 'external_network_id', 'external_network_id': 'external_network_id',
'fixed_network': '10.2.0.0/22', 'fixed_network': '10.2.0.0/22',
'cluster_distro': 'fedora-atomic', 'cluster_distro': 'fedora-atomic',
@ -80,6 +81,7 @@ class TestBayConductorWithSwarm(base.TestCase):
'server_image': 'image_id', 'server_image': 'image_id',
'server_flavor': 'flavor_id', 'server_flavor': 'flavor_id',
'number_of_nodes': '1', 'number_of_nodes': '1',
'docker_volume_size': 20,
'fixed_network_cidr': '10.2.0.0/22', 'fixed_network_cidr': '10.2.0.0/22',
'discovery_url': 'token://39987da72f8386e0d0225ae8929e7cb4', 'discovery_url': 'token://39987da72f8386e0d0225ae8929e7cb4',
'http_proxy': 'http_proxy', 'http_proxy': 'http_proxy',
@ -102,8 +104,8 @@ class TestBayConductorWithSwarm(base.TestCase):
'test_discovery', group='bay') 'test_discovery', group='bay')
not_required = ['image_id', 'flavor_id', 'dns_nameserver', not_required = ['image_id', 'flavor_id', 'dns_nameserver',
'fixed_network', 'http_proxy', 'https_proxy', 'docker_volume_size', 'fixed_network', 'http_proxy',
'no_proxy'] 'https_proxy', 'no_proxy']
for key in not_required: for key in not_required:
self.baymodel_dict[key] = None self.baymodel_dict[key] = None
self.bay_dict['discovery_url'] = None self.bay_dict['discovery_url'] = None