Make docker_storage_driver a str instead of enum

Allow any value to be passed on the docker_storage_driver field by turning it
into a StringField (was EnumField), and remove the constraints limiting the
values to 'devicemapper' and 'overlay'.

Change the docker storage setup to have a generic setup for all drivers with
the exception of 'devicemapper', which keeps its own specific storage config
function. For all others, do the same we already did for overlay (with two
cases for usage of a cinder volume or not) and simply set the storage driver
in the docker configuration to the value provided in the cluster template.

Change-Id: I9aa8f232ce64ece4d439c0a476f463820a499617
Closes-Bug: #1722522
This commit is contained in:
Ricardo Rocha 2017-10-10 13:17:51 +00:00
parent 46b265ed47
commit 28fff8006a
23 changed files with 60 additions and 69 deletions

View File

@ -225,8 +225,7 @@ dns_nameserver:
docker_storage_driver:
description: |
The name of a driver to manage the storage for the images and the
container's writable layer. The supported drivers are ``devicemapper`` and
``overlay``. The default is ``devicemapper``.
container's writable layer. The default is ``devicemapper``.
in: body
required: true
type: string

View File

@ -236,8 +236,7 @@ They are loosely grouped as: mandatory, infrastructure, COE specific.
--docker-storage-driver \<docker-storage-driver\>
The name of a driver to manage the storage for the images and the
container's writable layer. The supported drivers are 'devicemapper'
and 'overlay'. The default is 'devicemapper'.
container's writable layer. The default is 'devicemapper'.
--labels \<KEY1=VALUE1,KEY2=VALUE2;KEY3=VALUE3...\>
Arbitrary labels in the form of key=value pairs. The accepted keys
@ -1025,8 +1024,7 @@ Volume driver (volume-driver)
Storage driver (docker-storage-driver)
Specified in the ClusterTemplate to select the Docker storage driver. The
supported storage drivers are 'devicemapper' and 'overlay', with
'devicemapper' being the default. Refer to the `Storage`_ section for more
default is 'devicemapper'. Refer to the `Storage`_ section for more
details.
Image (image)
@ -1203,8 +1201,7 @@ Volume driver (volume-driver)
Storage driver (docker-storage-driver)
Specified in the ClusterTemplate to select the Docker storage driver. The
supported storage driver are 'devicemapper' and 'overlay', with
'devicemapper' being the default. Refer to the `Storage`_ section for more
default is 'devicemapper'. Refer to the `Storage`_ section for more
details.
Image (image)

View File

@ -127,7 +127,7 @@ class BayModel(base.APIBase):
insecure_registry = wtypes.StringType(min_length=1, max_length=255)
"""Insecure registry URL when creating a Baymodel"""
docker_storage_driver = wtypes.Enum(str, *fields.DockerStorageDriver.ALL)
docker_storage_driver = wtypes.StringType(min_length=1, max_length=255)
"""Docker storage driver"""
master_lb_enabled = wsme.wsattr(types.boolean, default=False)

View File

@ -128,7 +128,7 @@ class ClusterTemplate(base.APIBase):
insecure_registry = wtypes.StringType(min_length=1, max_length=255)
"""Insecure registry URL when creating a ClusterTemplate """
docker_storage_driver = wtypes.Enum(str, *fields.DockerStorageDriver.ALL)
docker_storage_driver = wtypes.StringType(min_length=1, max_length=255)
"""Docker storage driver"""
master_lb_enabled = wsme.wsattr(types.boolean, default=False)

View File

@ -0,0 +1,33 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""change storage driver to string
Revision ID: 04c625aa95ba
Revises: 52bcaf58fecb
Create Date: 2017-10-10 15:40:37.553288
"""
# revision identifiers, used by Alembic.
revision = '04c625aa95ba'
down_revision = '52bcaf58fecb'
from alembic import op
import sqlalchemy as sa
def upgrade():
op.alter_column('cluster_template', 'docker_storage_driver',
existing_type=sa.Enum('devicemapper', 'overlay',
name='docker_storage_driver'),
type_=sa.String(length=512),
nullable=True)

View File

@ -32,14 +32,8 @@ fi
$configure_docker_storage_driver
if [ "$DOCKER_STORAGE_DRIVER" = "overlay" ]; then
if [ $(echo -e "$(uname -r)\n3.18" | sort -V | head -1) = $(uname -r) ]; then
ERROR_MESSAGE="OverlayFS requires at least Linux kernel 3.18. Cluster node kernel version: $(uname -r)"
echo "ERROR: ${ERROR_MESSAGE}" >&2
sh -c "${WAIT_CURL} --data-binary '{\"status\": \"FAILURE\", \"reason\": \"${ERROR_MESSAGE}\"}'"
else
configure_overlay
fi
else
if [ "$DOCKER_STORAGE_DRIVER" = "devicemapper" ]; then
configure_devicemapper
else
configure_storage_driver_generic $DOCKER_STORAGE_DRIVER
fi

View File

@ -1,5 +1,5 @@
# This file contains docker storage drivers configuration for fedora
# atomic hosts. Currently, devicemapper and overlay are supported.
# atomic hosts, as supported by Magnum.
# * Remove any existing docker-storage configuration. In case of an
# existing configuration, docker-storage-setup will fail.
@ -17,8 +17,8 @@ clear_docker_storage () {
fi
}
# Configure docker storage with xfs as backing filesystem.
configure_overlay () {
# Configure generic docker storage driver.
configure_storage_driver_generic() {
clear_docker_storage
if [ -n "$DOCKER_VOLUME_SIZE" ] && [ "$DOCKER_VOLUME_SIZE" -gt 0 ]; then
@ -27,9 +27,7 @@ configure_overlay () {
mount -a
fi
echo "STORAGE_DRIVER=overlay" > /etc/sysconfig/docker-storage-setup
docker-storage-setup
sed -i "/^DOCKER_STORAGE_OPTIONS=/ s/=.*/=-s $1/" /etc/sysconfig/docker-storage
local lvname=$(lvdisplay | grep "LV\ Path" | awk '{print $3}')
local pvname=$(pvdisplay | grep "PV\ Name" | awk '{print $3}')

View File

@ -153,8 +153,6 @@ parameters:
type: string
description: docker storage driver name
default: "devicemapper"
constraints:
- allowed_values: ["devicemapper", "overlay"]
wait_condition_timeout:
type: number

View File

@ -60,8 +60,6 @@ parameters:
type: string
description: docker storage driver name
default: "devicemapper"
constraints:
- allowed_values: ["devicemapper", "overlay"]
volume_driver:
type: string

View File

@ -50,8 +50,6 @@ parameters:
type: string
description: docker storage driver name
default: "devicemapper"
constraints:
- allowed_values: ["devicemapper", "overlay"]
tls_disabled:
type: boolean

View File

@ -151,8 +151,6 @@ parameters:
type: string
description: docker storage driver name
default: "devicemapper"
constraints:
- allowed_values: ["devicemapper", "overlay"]
wait_condition_timeout:
type: number

View File

@ -49,8 +49,6 @@ parameters:
type: string
description: docker storage driver name
default: "devicemapper"
constraints:
- allowed_values: ["devicemapper", "overlay"]
flannel_network_cidr:
type: string

View File

@ -22,8 +22,6 @@ parameters:
type: string
description: docker storage driver name
default: "devicemapper"
constraints:
- allowed_values: ["devicemapper", "overlay"]
tls_disabled:
type: boolean

View File

@ -144,8 +144,6 @@ parameters:
type: string
description: docker storage driver name
default: "devicemapper"
constraints:
- allowed_values: ["devicemapper", "overlay"]
loadbalancing_protocol:
type: string

View File

@ -29,8 +29,6 @@ parameters:
docker_storage_driver:
type: string
description: docker storage driver name
constraints:
- allowed_values: ["devicemapper", "overlay"]
external_network:
type: string

View File

@ -38,8 +38,6 @@ parameters:
docker_storage_driver:
type: string
description: docker storage driver name
constraints:
- allowed_values: ["devicemapper", "overlay"]
external_network:
type: string

View File

@ -116,8 +116,6 @@ parameters:
type: string
description: docker storage driver name
default: "devicemapper"
constraints:
- allowed_values: ["devicemapper", "overlay"]
loadbalancing_protocol:
type: string

View File

@ -30,8 +30,6 @@ parameters:
docker_storage_driver:
type: string
description: docker storage driver name
constraints:
- allowed_values: ["devicemapper", "overlay"]
external_network:
type: string

View File

@ -38,8 +38,6 @@ parameters:
docker_storage_driver:
type: string
description: docker storage driver name
constraints:
- allowed_values: ["devicemapper", "overlay"]
external_network:
type: string

View File

@ -41,7 +41,8 @@ class ClusterTemplate(base.MagnumPersistentObject, base.MagnumObject,
# Version 1.15: Added 'floating_ip_enabled' field
# Version 1.16: Renamed the class from "BayModel' to 'ClusterTemplate'
# Version 1.17: 'coe' field type change to ClusterTypeField
VERSION = '1.17'
# Version 1.18: DockerStorageDriver is a StringField (was an Enum)
VERSION = '1.18'
dbapi = dbapi.get_instance()
@ -63,8 +64,7 @@ class ClusterTemplate(base.MagnumPersistentObject, base.MagnumObject,
'volume_driver': fields.StringField(nullable=True),
'apiserver_port': fields.IntegerField(nullable=True),
'docker_volume_size': fields.IntegerField(nullable=True),
'docker_storage_driver': m_fields.DockerStorageDriverField(
nullable=True),
'docker_storage_driver': fields.StringField(nullable=True),
'cluster_distro': fields.StringField(nullable=True),
'coe': m_fields.ClusterTypeField(nullable=True),
'http_proxy': fields.StringField(nullable=True),

View File

@ -72,18 +72,6 @@ class ClusterType(fields.Enum):
super(ClusterType, self).__init__(valid_values=ClusterType.ALL)
class DockerStorageDriver(fields.Enum):
ALL = (
DEVICEMAPPER, OVERLAY,
) = (
'devicemapper', 'overlay',
)
def __init__(self):
super(DockerStorageDriver, self).__init__(
valid_values=DockerStorageDriver.ALL)
class QuotaResourceName(fields.Enum):
ALL = (
CLUSTER,
@ -156,9 +144,5 @@ class ClusterTypeField(fields.BaseEnumField):
AUTO_TYPE = ClusterType()
class DockerStorageDriverField(fields.BaseEnumField):
AUTO_TYPE = DockerStorageDriver()
class ServerTypeField(fields.BaseEnumField):
AUTO_TYPE = ServerType()

View File

@ -356,7 +356,7 @@ class TestObject(test_base.TestCase, _TestObject):
# http://docs.openstack.org/developer/magnum/objects.html
object_data = {
'Cluster': '1.16-7a544c5059697c464810470980f81ba1',
'ClusterTemplate': '1.17-f1ce5212b46506360b41ab5cb7658af4',
'ClusterTemplate': '1.18-7fa94f4fdd027acfb4f022f202afdfb5',
'Certificate': '1.1-1924dc077daa844f0f9076332ef96815',
'MyObj': '1.0-34c4b1aadefd177b13f9a2f894cc23cd',
'X509KeyPair': '1.2-d81950af36c59a71365e33ce539d24f9',

View File

@ -0,0 +1,10 @@
---
features:
- |
Allow any value to be passed on the docker_storage_driver field by turning it
into a StringField (was EnumField), and remove the constraints limiting the
values to 'devicemapper' and 'overlay'.
upgrade:
- |
Requires a db upgrade to change the docker_storage_driver
field to be a string instead of an enum.