Browse Source

Merge "Fix Docker storage configuration for Swarm"

changes/32/269532/1
Jenkins 6 years ago
committed by Gerrit Code Review
parent
commit
4c0864d2bb
  1. 23
      magnum/templates/swarm/fragments/configure-docker-storage.sh
  2. 7
      magnum/templates/swarm/fragments/configure-swarm.sh
  3. 2
      magnum/templates/swarm/fragments/network-config-service.sh
  4. 2
      magnum/templates/swarm/fragments/network-service.sh
  5. 2
      magnum/templates/swarm/fragments/write-docker-service.sh
  6. 1
      magnum/templates/swarm/fragments/write-docker-socket.yaml
  7. 1
      magnum/templates/swarm/swarmcluster.yaml
  8. 33
      magnum/templates/swarm/swarmmaster.yaml
  9. 7
      magnum/templates/swarm/swarmnode.yaml
  10. 4
      magnum/tests/functional/common/datagen.py
  11. 2
      magnum/tests/functional/swarm/test_swarm_python_client.py

23
magnum/templates/swarm/fragments/configure-docker-storage.sh

@ -2,24 +2,29 @@
. /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"
while [ ${attempts} -gt 0 ]; do
device_name=$(ls /dev/disk/by-id | grep ${DOCKER_VOLUME:0:20}$)
if [ -n "${device_name}" ]; then
break
fi
echo "waiting for disk device"
sleep 0.5
udevadm trigger
let attempts--
done
if ! [ -b $DOCKER_DEV ]; then
echo "ERROR: device $DOCKER_DEV does not exist" >&2
if [ -z "${device_name}" ]; then
echo "ERROR: disk device does not exist" >&2
exit 1
fi
pvcreate $DOCKER_DEV
vgcreate docker $DOCKER_DEV
device_path=/dev/disk/by-id/${device_name}
pvcreate ${device_path}
vgcreate docker ${device_path}
cat > /etc/sysconfig/docker-storage-setup <<EOF
cat > /etc/sysconfig/docker-storage-setup << EOF
VG=docker
EOF
sed -i '/^DOCKER_STORAGE_OPTIONS=/ s/=.*/=--storage-driver devicemapper --storage-opt dm.fs=xfs --storage-opt dm.thinpooldev=\/dev\/mapper\/docker-docker--pool --storage-opt dm.use_deferred_removal=true/' /etc/sysconfig/docker-storage

7
magnum/templates/swarm/fragments/configure-swarm.sh

@ -1,7 +0,0 @@
#!/bin/sh
# This shell script will do some extra configure stuff before running services
echo "configuring swarm ..."
# Add --storage-driver devicemapper to DOCKER_STORAGE_OPTIONS
sed -i '/^DOCKER_STORAGE_OPTIONS=/ s/=.*/=--storage-driver devicemapper --storage-opt dm.fs=xfs --storage-opt dm.datadev=\/dev\/mapper\/atomicos-docker--data --storage-opt dm.metadatadev=\/dev\/mapper\/atomicos-docker--meta/' /etc/sysconfig/docker-storage

2
magnum/templates/swarm/fragments/network-config-service.sh

@ -2,6 +2,8 @@
. /etc/sysconfig/heat-params
echo "Configuring ${NETWORK_DRIVER} network ..."
if [ "$NETWORK_DRIVER" != "flannel" ]; then
exit 0
fi

2
magnum/templates/swarm/fragments/network-service.sh

@ -2,6 +2,8 @@
. /etc/sysconfig/heat-params
echo "Configuring ${NETWORK_DRIVER} network service ..."
if [ "$NETWORK_DRIVER" != "flannel" ]; then
exit 0
fi

2
magnum/templates/swarm/fragments/write-docker-service.sh

@ -10,6 +10,7 @@ Description=Docker Application Container Engine
Documentation=http://docs.docker.com
After=network.target docker.socket
Requires=docker.socket
Wants=docker-storage-setup.service
[Service]
TimeoutStartSec=300
@ -17,6 +18,7 @@ Type=notify
EnvironmentFile=-/etc/sysconfig/docker
EnvironmentFile=-/etc/sysconfig/docker-storage
EnvironmentFile=-/etc/sysconfig/docker-network
Environment=GOTRACEBACK=crash
ExecStart=/usr/bin/docker daemon -H fd:// \\
-H tcp://0.0.0.0:2375 \\
END_SERVICE_TOP

1
magnum/templates/swarm/fragments/write-docker-socket.yaml

@ -8,6 +8,7 @@ write_files:
[Unit]
Description=Docker Socket for the API
PartOf=docker.service
After=docker-storage-setup.service
[Socket]
ListenStream=/var/run/docker.sock

1
magnum/templates/swarm/swarmcluster.yaml

@ -270,6 +270,7 @@ resources:
ssh_key_name: {get_param: ssh_key_name}
server_image: {get_param: server_image}
server_flavor: {get_param: master_flavor}
docker_volume_size: {get_param: docker_volume_size}
fixed_network_id: {get_resource: fixed_network}
fixed_subnet_id: {get_resource: fixed_subnet}
external_network: {get_param: external_network}

33
magnum/templates/swarm/swarmmaster.yaml

@ -10,6 +10,12 @@ parameters:
type: string
description: name of ssh key to be provisioned on our server
docker_volume_size:
type: number
description: >
size of a cinder volume to allocate to docker for container/image
storage
external_network:
type: string
description: uuid/name of a network to use for floating ip addresses
@ -155,6 +161,7 @@ resources:
template: {get_file: fragments/write-heat-params.yaml}
params:
"$WAIT_HANDLE": {get_resource: cloud_init_wait_handle}
"$DOCKER_VOLUME": {get_resource: docker_volume}
"$ETCD_DISCOVERY_URL": {get_param: discovery_url}
"$HTTP_PROXY": {get_param: http_proxy}
"$HTTPS_PROXY": {get_param: https_proxy}
@ -171,6 +178,7 @@ resources:
"$FLANNEL_USE_VXLAN": {get_param: flannel_use_vxlan}
"$ETCD_SERVER_IP": {get_param: etcd_server_ip}
"$API_IP_ADDRESS": {get_param: api_ip_address}
"$SWARM_VERSION": {get_param: swarm_version}
write_network_config:
type: "OS::Heat::SoftwareConfig"
@ -202,6 +210,12 @@ resources:
group: ungrouped
config: {get_file: fragments/remove-docker-key.sh}
configure_docker_storage:
type: OS::Heat::SoftwareConfig
properties:
group: ungrouped
config: {get_file: fragments/configure-docker-storage.sh}
make_cert:
type: "OS::Heat::SoftwareConfig"
properties:
@ -289,6 +303,7 @@ resources:
- config: {get_resource: write_network_config}
- config: {get_resource: network_config_service}
- config: {get_resource: network_service}
- config: {get_resource: configure_docker_storage}
- config: {get_resource: write_swarm_manager_failure_service}
- config: {get_resource: write_docker_service}
- config: {get_resource: write_docker_socket}
@ -351,6 +366,24 @@ resources:
address: {get_attr: [swarm_master_eth0, fixed_ips, 0, ip_address]}
protocol_port: 2379
######################################################################
#
# 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_master}
volume_id: {get_resource: docker_volume}
mountpoint: /dev/vdb
outputs:
swarm_master_ip:

7
magnum/templates/swarm/swarmnode.yaml

@ -148,12 +148,6 @@ resources:
"$SWARM_VERSION": {get_param: swarm_version}
"$AGENT_WAIT_HANDLE": {get_resource: node_agent_wait_handle}
configure_swarm:
type: "OS::Heat::SoftwareConfig"
properties:
group: ungrouped
config: {get_file: fragments/configure-swarm.sh}
remove_docker_key:
type: "OS::Heat::SoftwareConfig"
properties:
@ -249,7 +243,6 @@ resources:
- config: {get_resource: write_swarm_agent_service}
- config: {get_resource: write_docker_service}
- config: {get_resource: write_docker_socket}
- config: {get_resource: configure_swarm}
- config: {get_resource: add_proxy}
- config: {get_resource: enable_services}
- config: {get_resource: cfn_signal}

4
magnum/tests/functional/common/datagen.py

@ -42,7 +42,7 @@ def gen_random_port():
return random_int(49152, 65535)
def gen_docker_volume_size(min_int=1, max_int=3):
def gen_docker_volume_size(min_int=3, max_int=5):
return random_int(min_int, max_int)
@ -91,7 +91,7 @@ def baymodel_data(**kwargs):
"coe": "swarm",
"tls_disabled": False,
"network_driver": None,
"docker_volume_size": 1,
"docker_volume_size": 3,
"labels": {},
"fixed_network": "192.168.0.0/24",
"dns_nameserver": "8.8.8.8",

2
magnum/tests/functional/swarm/test_swarm_python_client.py

@ -51,7 +51,7 @@ class TestSwarmAPIs(BayAPITLSTest):
coe='swarm',
tls_disabled=False,
network_driver=None,
docker_volume_size=5,
docker_volume_size=3,
labels={},
fixed_network='192.168.0.0/24',
dns_nameserver='8.8.8.8')

Loading…
Cancel
Save