Update BlockBox

There have been a number of changes to LOCI since the introduction
of BlockBox.  In particular LOCI now offers a `universal` Dockerfile
and employees bindeps and new ARGS features of Docker to customize
images.

This patch modifies BlockBox to use the new universal LOCI repo and
also cleans up a bunch of cruft and adds an updated conf entry with
key-manager.

This patch also removes the dev environment as it's out dated and
doesn't seem to be gaining much usage.  It's easy enough to set
this up on your own, so rather than maintain it just remove it.

Change-Id: Id03ff9310fd53c4e6df300f2866b7a17cba82561
This commit is contained in:
John Griffith 2017-10-04 13:59:01 -06:00
parent 9e164a2acc
commit 3a2205e393
21 changed files with 70 additions and 2228 deletions

1
.gitignore vendored
View File

@ -37,3 +37,4 @@ api-ref/build
# Files created by releasenotes build
releasenotes/build
contrib/blockbox/.db_data

View File

@ -1 +1 @@
db-data/*
./.db_data/*

View File

@ -1,17 +1,21 @@
CINDER_BRANCH ?= master # master, stable/ocata, refs/changes/67/418167/1
CINDER_BRANCH ?= master# master, stable/ocata, refs/changes/67/418167/1
NAME_PREFIX ?= ""
PLATFORM ?= debian # ubuntu, centos
TAG ?= latest
PLATFORM ?= debian:stretch# ubuntu:xenial, centos:7
TAG ?= debian-cinder:latest
all: base lvm devbox
all: base lvm
blockbox: base lvm
base:
docker build https://git.openstack.org/openstack/loci-cinder.git\#:$(PLATFORM) --tag cinder:$(TAG) --build-arg PROJECT_REF=$(CINDER_BRANCH)
docker build https://git.openstack.org/openstack/loci.git \
--build-arg PROJECT=cinder \
--build-arg FROM=$(PLATFORM) \
--build-arg PROJECT_REF=$(CINDER_BRANCH) \
--tag $(TAG)
lvm:
docker build -t cinder-lvm -f ./docker_files/Dockerfile.cinder-lvm .
devbox:
cp ../../test-requirements.txt ./docker_files/
docker build -t cinder-devenv -f ./docker_files/Dockerfile.cinder-devenv .
rm ./docker_files/test-requirements.txt
docker build https://git.openstack.org/openstack/loci.git \
--build-arg PROJECT=cinder \
--build-arg FROM=$(PLATFORM) \
--build-arg PROJECT_REF=$(CINDER_BRANCH) \
--build-arg PROFILES="lvm" \
--tag lvm-$(TAG)

View File

@ -35,10 +35,13 @@ You can also build an image to run LVM (**NOTE**: This is dependent on the base
```make lvm```
Finally the last image is a devenv image that will mount the cinder repo you've
checked out into a container and includes test-requirements:
To build both the base and lvm enabled image
```make blockbox```
```make devbox```
All we're doing here is a ```docker build``` utilizing the loci
Dockerfile and bindeps. Currently loci images are not published
regulary (although they will be in the future) so we require you
to build images before running docker-compose up.
For more information and options, check out the openstack/loci page
on [github](https://github.com/openstack/loci).
@ -49,12 +52,6 @@ Images. The build has been known to now work at times, and if it becomes
bloated or burdensome it's easy to swap in another image builder (or write your
own even).
This will result in some base images that we'll use:
1. cinder (openstack/loci image)
2. cinder-lvm (special cinder image with LVM config)
3. cinder-devenv (provides a Cinder development env container)
### cinder
Creates a base image with cinder installed via source. This base image is
enough to run all of the services including api, scheduler and volume with
@ -70,40 +67,11 @@ base, you'll need to modify the Makefile for this image as well.
This is a special image that is built from the base cinder image and adds the
necessary packages for LVM and iSCSI.
### cinder-devenv
You might want to generate a conf file, or if you're like me, use Docker to do
some of your Cinder development. You can run this container which has all of
the current development packages and python test-requirements for Cinder.
You can pass in your current source directory from your local machine using -v
in your run command, here's a trivial example that generates a sample config
file. Note we don't use tox because we're already in an isolated environment.
```shell
docker run -it -v /home/jgriffith/src/cinder:/cinder \
cinder-devenv \
bash -c "cd cinder && oslo-config-generator \
--config-file=cinder/config/cinder-config-generator.conf"
```
Keep in mind the command will execute and then exit, the result is written to
the cinder directory specified in the -v argument. In this example for
instance the result would be a newly generated cinder.conf.sample file in
/home/jgriffith/src/cinder/etc/cinder
## Accessing via cinderclient
You can of course build a cinderclient container with a `cinder` entrypoint and
use that for access, but in order to take advantage of things like the
local-attach extension, you'll need to install the client tools on the host.
The current release version in pypi doesn't include noauth
support, so you'll need to install from source, but that's not hard:
```shell
sudo pip install pytz
sudo pip install git+https://github.com/openstack/python-cinderclient
sudo pip install git+https://github.com/openstack/python-brick-cinderclient-ext
```
Before using, you must specify these env variables at least,
``OS_AUTH_TYPE``, ``CINDER_ENDPOINT``, ``OS_PROJECT_ID``, ``OS_USERNAME``.
You can utilize our sample file ``cinder.rc``, then you can use client
@ -117,9 +85,11 @@ sudo. To preserve your env variables don't forget to use `sudo -E cinder xxxxx`
docker-compose up -d
Don't forget to modify the `etc-cinder/cinder.conf` file as needed for your
specific driver. We'll be adding support for the LVM driver and LIO Tgts
shortly, but for now you won't have much luck without using an external
device (no worries, there are over 80 to choose from).
specific driver. The current default setup should give you the ability to
quickly deploy a fully functional stand-alone cinder deployment with LVM.
If you'd like to add your own external driver, it's quite simple, and we've
included an example for adding an additional volume service to the base
deployment/compose. See the section below for more details.
**Note**: If you use ``cinder-lvm`` image, you must guarantee the required
volume group which is specified in the ``cinder.conf`` already exists in
@ -161,18 +131,6 @@ docker run -it -e OS_AUTH_TYPE=noauth \
--network blockbox_default cinderclient list
```
# Or without docker-compose
That's ok, you can always just run the commands yourself using docker run:
```shell
# We set passwords and db creation in the docker-entrypoint-initdb.d script
docker run -d -p 3306:3306 \
-v ~/block-box/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d \
--name mariadb \
--hostname mariadb \
-e MYSQL_ROOT_PASSWORD=password \
mariadb
# Make sure the environment vars match the startup script for your database host
docker run -d -p 5000:5000 \
-p 35357:35357 \

View File

@ -5,7 +5,7 @@ services:
hostname: cinder-volume-sf
privileged: true
volumes:
- ./etc-cinder:/etc/cinder
- ./etc:/etc/cinder
- /dev/:/dev/
- /run/:/run/:shared
- /etc/localtime:/etc/localtime:ro

View File

@ -19,14 +19,14 @@ services:
cindernet:
ipv4_address: 172.49.49.6
volumes:
- ./db-data:/var/lib/mysql
- ./.db_data:/var/lib/mysql
- ./docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
cinder-api:
image: cinder
image: debian-cinder
hostname: cinder-api
volumes:
- ./etc-cinder:/etc/cinder
- ./init-scripts:/init-scripts
- ./etc:/etc/cinder
- ./scripts:/scripts
network_mode: "host"
ports:
- 8776:8776
@ -37,12 +37,12 @@ services:
- "mariadb:172.49.49.6"
environment:
- INIT_DB=true
command: sh /init-scripts/cinder-api.sh
command: sh /scripts/cinder-api.sh
cinder-scheduler:
image: cinder
image: debian-cinder
hostname: cinder-scheduler
volumes:
- ./etc-cinder:/etc/cinder
- ./etc:/etc/cinder
depends_on:
- mariadb
- rabbitmq
@ -56,15 +56,16 @@ services:
restart: on-failure
command: cinder-scheduler
cinder-volume:
image: cinder-lvm
image: lvm-debian-cinder
hostname: cinder-lvm
privileged: true
volumes:
- ./etc-cinder:/etc/cinder
- ./etc:/etc/cinder
- /dev/:/dev/
- /run/:/run/:shared
- /etc/localtime:/etc/localtime:ro
- /lib/modules:/lib/modules:ro
- ./scripts:/scripts
depends_on:
- cinder-scheduler
ports:
@ -74,7 +75,7 @@ services:
- "mariadb:172.49.49.6"
network_mode: "host"
restart: on-failure
command: bash -c "sleep 5 && /usr/sbin/tgtd && cinder-volume -d"
command: bash -c "/scripts/lvm-service.sh"
networks:
cindernet:

View File

@ -1,12 +0,0 @@
FROM python
COPY test-requirements.txt /test-requirements.txt
RUN apt-get update \
&& apt-get install -y \
libssl-dev \
git-core \
libmysqlclient-dev \
libpq-dev \
libffi-dev \
libxslt-dev \
&& pip install -r test-requirements.txt \
&& rm -rf /var/lib/apt/lists/*

View File

@ -1,11 +0,0 @@
FROM cinder
RUN DEBIAN_FRONTEND=noninteractive apt-get update \
&& apt-get install -y --no-install-recommends \
vim lvm2 tgt \
&& rm -rf /var/lib/apt
RUN sed -i -e 's/udev_sync = 1/udev_sync = 0/g' /etc/lvm/lvm.conf \
&& sed -i -e 's/udev_rules = 1/udev_rules = 0/g' /etc/lvm/lvm.conf \
&& sed -i -e 's/use_lvmetad = 0/use_lvmetad =1/g' /etc/lvm/lvm.conf \
&& echo "include /var/lib/cinder/volumes/*" >> /etc/tgt/targets.conf
CMD /usr/sbin/tgtd

View File

@ -1,6 +0,0 @@
Need to turn off udev_ rules
s/udev_sync = 1/udev_sync = 0/
s/udev_rules = 1/udev_rules = 0/
Need to turn ON use_lvmetad
s/use_lvmetad = 0/use_lvmetad = 1/

File diff suppressed because it is too large Load Diff

View File

@ -11,6 +11,9 @@ volumes_dir = /var/lib/cinder/volumes
rabbit_host = rabbitmq
enabled_backends = lvm
[key_manager]
backend = cinder.keymgr.conf_key_mgr.ConfKeyManager
[database]
connection = mysql+pymysql://cinder:password@mariadb/cinder?charset=utf8

View File

@ -0,0 +1,26 @@
#!/bin/bash
YUM = $(which yum)
APT = $(which apt-get)
# There's a few things that aren't in the older LOCI images,
# we'll add them here just to be safe
if [[ ! -z $YUM ]]; then
yum install -y epel-release
yum update -y
yum install -y scsi-target-utils
elif [[ ! -z $APT ]]; then
apgt-get update -y
apt-get install -y thin-provisioning-tools
else:
echo "I don't know how to install with this package manager"
exit 1;
fi
sed -i -e 's/udev_sync = 1/udev_sync = 0/g' /etc/lvm/lvm.conf
sed -i -e 's/udev_rules = 1/udev_rules = 0/g' /etc/lvm/lvm.conf
sed -i -e 's/use_lvmetad = 0/use_lvmetad =1/g' /etc/lvm/lvm.conf
echo "include /var/lib/cinder/volumes/*" >> /etc/tgt/targets.conf
/usr/sbin/tgtd
cinder-volume -d

View File

@ -1,27 +0,0 @@
# The order of packages is significant, because pip processes them in the order
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
# Install bounded pep8/pyflakes first, then let flake8 install
hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0
coverage>=4.0 # Apache-2.0
ddt>=1.0.1 # MIT
fixtures>=3.0.0 # Apache-2.0/BSD
mock>=2.0 # BSD
os-api-ref>=1.0.0 # Apache-2.0
oslotest>=1.10.0 # Apache-2.0
sphinx>=1.5.1 # BSD
PyMySQL>=0.7.6 # MIT License
psycopg2>=2.5 # LGPL/ZPL
python-subunit>=0.0.18 # Apache-2.0/BSD
testtools>=1.4.0 # MIT
testresources>=0.2.4 # Apache-2.0/BSD
testscenarios>=0.4 # Apache-2.0/BSD
oslosphinx>=4.7.0 # Apache-2.0
oslo.versionedobjects[fixtures]>=1.17.0 # Apache-2.0
os-testr>=0.8.0 # Apache-2.0
tempest>=14.0.0 # Apache-2.0
bandit>=1.1.0 # Apache-2.0
reno>=1.8.0 # Apache-2.0
doc8 # Apache-2.0