diff --git a/docker/centos/binary/cinder-app/cinder-api/Dockerfile b/docker/centos/binary/cinder-app/cinder-api/Dockerfile index 3d3e3ae8f6..c96caaeccb 100644 --- a/docker/centos/binary/cinder-app/cinder-api/Dockerfile +++ b/docker/centos/binary/cinder-app/cinder-api/Dockerfile @@ -2,6 +2,7 @@ FROM %%KOLLA_NAMESPACE%%/%%KOLLA_PREFIX%%cinder-base:%%KOLLA_TAG%% MAINTAINER Kolla Project (https://launchpad.net/kolla) RUN yum install -y python-keystone && yum clean all +COPY config-internal.sh config-external.sh /opt/kolla/ COPY ./start.sh ./check.sh / CMD ["/start.sh"] diff --git a/docker/centos/binary/cinder-app/cinder-api/config-external.sh b/docker/centos/binary/cinder-app/cinder-api/config-external.sh new file mode 120000 index 0000000000..5b577f2903 --- /dev/null +++ b/docker/centos/binary/cinder-app/cinder-api/config-external.sh @@ -0,0 +1 @@ +../../../../common/cinder-app/cinder-api/config-external.sh \ No newline at end of file diff --git a/docker/centos/binary/cinder-app/cinder-api/config-internal.sh b/docker/centos/binary/cinder-app/cinder-api/config-internal.sh new file mode 120000 index 0000000000..d929c89b20 --- /dev/null +++ b/docker/centos/binary/cinder-app/cinder-api/config-internal.sh @@ -0,0 +1 @@ +../../../../common/cinder-app/cinder-api/config-internal.sh \ No newline at end of file diff --git a/docker/centos/binary/cinder-app/cinder-backup/Dockerfile b/docker/centos/binary/cinder-app/cinder-backup/Dockerfile index fb44155b30..43994f1238 100644 --- a/docker/centos/binary/cinder-app/cinder-backup/Dockerfile +++ b/docker/centos/binary/cinder-app/cinder-backup/Dockerfile @@ -2,5 +2,6 @@ FROM %%KOLLA_NAMESPACE%%/%%KOLLA_PREFIX%%cinder-base:%%KOLLA_TAG%% MAINTAINER Kolla Project (https://launchpad.net/kolla) COPY ./start.sh /start.sh +COPY config-internal.sh config-external.sh /opt/kolla/ CMD ["/start.sh"] diff --git a/docker/centos/binary/cinder-app/cinder-backup/config-external.sh b/docker/centos/binary/cinder-app/cinder-backup/config-external.sh new file mode 120000 index 0000000000..c80c21a204 --- /dev/null +++ b/docker/centos/binary/cinder-app/cinder-backup/config-external.sh @@ -0,0 +1 @@ +../../../../common/cinder-app/cinder-backup/config-external.sh \ No newline at end of file diff --git a/docker/centos/binary/cinder-app/cinder-backup/config-internal.sh b/docker/centos/binary/cinder-app/cinder-backup/config-internal.sh new file mode 120000 index 0000000000..5f135c63bb --- /dev/null +++ b/docker/centos/binary/cinder-app/cinder-backup/config-internal.sh @@ -0,0 +1 @@ +../../../../common/cinder-app/cinder-backup/config-internal.sh \ No newline at end of file diff --git a/docker/centos/binary/cinder-app/cinder-scheduler/Dockerfile b/docker/centos/binary/cinder-app/cinder-scheduler/Dockerfile index 344dc142f5..1014e3dcef 100644 --- a/docker/centos/binary/cinder-app/cinder-scheduler/Dockerfile +++ b/docker/centos/binary/cinder-app/cinder-scheduler/Dockerfile @@ -2,5 +2,6 @@ FROM %%KOLLA_NAMESPACE%%/%%KOLLA_PREFIX%%cinder-base:%%KOLLA_TAG%% MAINTAINER Kolla Project (https://launchpad.net/kolla) ADD ./start.sh /start.sh +COPY config-internal.sh config-external.sh /opt/kolla/ CMD ["/start.sh"] diff --git a/docker/centos/binary/cinder-app/cinder-scheduler/config-external.sh b/docker/centos/binary/cinder-app/cinder-scheduler/config-external.sh new file mode 120000 index 0000000000..9762490029 --- /dev/null +++ b/docker/centos/binary/cinder-app/cinder-scheduler/config-external.sh @@ -0,0 +1 @@ +../../../../common/cinder-app/cinder-scheduler/config-external.sh \ No newline at end of file diff --git a/docker/centos/binary/cinder-app/cinder-scheduler/config-internal.sh b/docker/centos/binary/cinder-app/cinder-scheduler/config-internal.sh new file mode 120000 index 0000000000..f3792cd9c4 --- /dev/null +++ b/docker/centos/binary/cinder-app/cinder-scheduler/config-internal.sh @@ -0,0 +1 @@ +../../../../common/cinder-app/cinder-scheduler/config-internal.sh \ No newline at end of file diff --git a/docker/centos/binary/cinder-app/cinder-volume/Dockerfile b/docker/centos/binary/cinder-app/cinder-volume/Dockerfile index d82fed03c3..0daf6d29e4 100644 --- a/docker/centos/binary/cinder-app/cinder-volume/Dockerfile +++ b/docker/centos/binary/cinder-app/cinder-volume/Dockerfile @@ -11,6 +11,7 @@ RUN yum install -y lvm2 scsi-target-utils && yum clean all # Add start scripts COPY start.sh /start.sh +COPY config-internal.sh config-external.sh /opt/kolla/ COPY volume-group-create.sh /opt/kolla/volume-group-create.sh # Start supervisor diff --git a/docker/centos/binary/cinder-app/cinder-volume/config-external.sh b/docker/centos/binary/cinder-app/cinder-volume/config-external.sh new file mode 120000 index 0000000000..1f6476f2eb --- /dev/null +++ b/docker/centos/binary/cinder-app/cinder-volume/config-external.sh @@ -0,0 +1 @@ +../../../../common/cinder-app/cinder-volume/config-external.sh \ No newline at end of file diff --git a/docker/centos/binary/cinder-app/cinder-volume/config-internal.sh b/docker/centos/binary/cinder-app/cinder-volume/config-internal.sh new file mode 120000 index 0000000000..4739be2fc5 --- /dev/null +++ b/docker/centos/binary/cinder-app/cinder-volume/config-internal.sh @@ -0,0 +1 @@ +../../../../common/cinder-app/cinder-volume/config-internal.sh \ No newline at end of file diff --git a/docker/common/cinder-app/cinder-api/config-external.sh b/docker/common/cinder-app/cinder-api/config-external.sh new file mode 100644 index 0000000000..5f57ab939a --- /dev/null +++ b/docker/common/cinder-app/cinder-api/config-external.sh @@ -0,0 +1,10 @@ +#!/bin/bash +SOURCE="/opt/kolla/cinder/cinder.conf" +TARGET="/etc/cinder/cinder.conf" +OWNER="cinder" + +if [[ -f "$SOURCE" ]]; then + cp $SOURCE $TARGET + chown ${OWNER}: $TARGET + chmod 0644 $TARGET +fi diff --git a/docker/common/cinder-app/cinder-api/config-internal.sh b/docker/common/cinder-app/cinder-api/config-internal.sh new file mode 100644 index 0000000000..832d4f78a1 --- /dev/null +++ b/docker/common/cinder-app/cinder-api/config-internal.sh @@ -0,0 +1,71 @@ +#!/bin/bash +set -e + +. /opt/kolla/kolla-common.sh +. /opt/kolla/config-cinder.sh + +check_required_vars KEYSTONE_ADMIN_TOKEN KEYSTONE_ADMIN_SERVICE_HOST \ + ADMIN_TENANT_NAME PUBLIC_IP CINDER_API_SERVICE_HOST \ + KEYSTONE_AUTH_PROTOCOL KEYSTONE_ADMIN_SERVICE_PORT \ + CINDER_KEYSTONE_USER CINDER_KEYSTONE_PASSWORD \ + CINDER_API_SERVICE_LISTEN CINDER_API_SERVICE_PORT + +fail_unless_os_service_running keystone + +cfg=/etc/cinder/cinder.conf + +# Set the auth credentials +export SERVICE_TOKEN="${KEYSTONE_ADMIN_TOKEN}" +export SERVICE_ENDPOINT="${KEYSTONE_AUTH_PROTOCOL}://${KEYSTONE_ADMIN_SERVICE_HOST}:${KEYSTONE_ADMIN_SERVICE_PORT}/v2.0" + +# Create Keystone User +crux user-create --update \ + -n "${CINDER_KEYSTONE_USER}" \ + -p "${CINDER_KEYSTONE_PASSWORD}" \ + -t "${ADMIN_TENANT_NAME}" \ + -r admin + +# Configure Keystone +crux endpoint-create --remove-all \ + -n cinder \ + -t volume \ + -P "http://${CINDER_API_SERVICE_HOST}:${CINDER_API_SERVICE_PORT}/v2/\$(tenant_id)s" \ + -A "http://${CINDER_API_SERVICE_HOST}:${CINDER_API_SERVICE_PORT}/v2/\$(tenant_id)s" \ + -I "http://${CINDER_API_SERVICE_HOST}:${CINDER_API_SERVICE_PORT}/v2/\$(tenant_id)s" + +crux endpoint-create --remove-all \ + -n cinderv2 \ + -t volumev2 \ + -P "http://${CINDER_API_SERVICE_HOST}:${CINDER_API_SERVICE_PORT}/v2/\$(tenant_id)s" \ + -A "http://${CINDER_API_SERVICE_HOST}:${CINDER_API_SERVICE_PORT}/v2/\$(tenant_id)s" \ + -I "http://${CINDER_API_SERVICE_HOST}:${CINDER_API_SERVICE_PORT}/v2/\$(tenant_id)s" + +# Logging +crudini --set $cfg \ + DEFAULT \ + log_file \ + "${CINDER_API_LOG_FILE}" + +# API Configuration +crudini --set $cfg \ + DEFAULT \ + osapi_volume_listen \ + "${CINDER_API_SERVICE_LISTEN}" + +crudini --set $cfg \ + DEFAULT \ + osapi_volume_listen_port \ + "${CINDER_API_SERVICE_PORT}" + +crudini --set $cfg \ + DEFAULT \ + enable_v1_api \ + "false" + +crudini --set $cfg \ + DEFAULT \ + enable_v2_api \ + "true" + +echo "Starting cinder-api" +exec /usr/bin/cinder-api --config-file $cfg diff --git a/docker/common/cinder-app/cinder-api/start.sh b/docker/common/cinder-app/cinder-api/start.sh index cbf0159e5e..4385d06311 100755 --- a/docker/common/cinder-app/cinder-api/start.sh +++ b/docker/common/cinder-app/cinder-api/start.sh @@ -1,72 +1,21 @@ #!/bin/bash -set -e +set -o errexit -. /opt/kolla/kolla-common.sh -. /opt/kolla/config-cinder.sh +CMD="/usr/bin/cinder-api" +ARGS="" -check_required_vars KEYSTONE_ADMIN_TOKEN KEYSTONE_ADMIN_SERVICE_HOST \ - ADMIN_TENANT_NAME PUBLIC_IP CINDER_API_SERVICE_HOST \ - KEYSTONE_AUTH_PROTOCOL KEYSTONE_ADMIN_SERVICE_PORT \ - CINDER_KEYSTONE_USER CINDER_KEYSTONE_PASSWORD \ - CINDER_API_SERVICE_LISTEN CINDER_API_SERVICE_PORT +# Loading common functions. +source /opt/kolla/kolla-common.sh -fail_unless_os_service_running keystone +# Config-internal script exec out of this function, it does not return here. +set_configs -cfg=/etc/cinder/cinder.conf +# Bootstrap and exit if KOLLA_BOOTSTRAP variable is set. This catches all cases +# of the KOLLA_BOOTSTRAP variable being set, including empty. +if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then + su -s /bin/sh -c "cinder-manage db_sync" cinder + exit 0 +fi -# Set the auth credentials -export SERVICE_TOKEN="${KEYSTONE_ADMIN_TOKEN}" -export SERVICE_ENDPOINT="${KEYSTONE_AUTH_PROTOCOL}://${KEYSTONE_ADMIN_SERVICE_HOST}:${KEYSTONE_ADMIN_SERVICE_PORT}/v2.0" - -# Create Keystone User -crux user-create --update \ - -n "${CINDER_KEYSTONE_USER}" \ - -p "${CINDER_KEYSTONE_PASSWORD}" \ - -t "${ADMIN_TENANT_NAME}" \ - -r admin - -# Configure Keystone -crux endpoint-create --remove-all \ - -n cinder \ - -t volume \ - -P "http://${CINDER_API_SERVICE_HOST}:${CINDER_API_SERVICE_PORT}/v2/\$(tenant_id)s" \ - -A "http://${CINDER_API_SERVICE_HOST}:${CINDER_API_SERVICE_PORT}/v2/\$(tenant_id)s" \ - -I "http://${CINDER_API_SERVICE_HOST}:${CINDER_API_SERVICE_PORT}/v2/\$(tenant_id)s" - -crux endpoint-create --remove-all \ - -n cinderv2 \ - -t volumev2 \ - -P "http://${CINDER_API_SERVICE_HOST}:${CINDER_API_SERVICE_PORT}/v2/\$(tenant_id)s" \ - -A "http://${CINDER_API_SERVICE_HOST}:${CINDER_API_SERVICE_PORT}/v2/\$(tenant_id)s" \ - -I "http://${CINDER_API_SERVICE_HOST}:${CINDER_API_SERVICE_PORT}/v2/\$(tenant_id)s" - -# Logging -crudini --set $cfg \ - DEFAULT \ - log_file \ - "${CINDER_API_LOG_FILE}" - -# API Configuration -crudini --set $cfg \ - DEFAULT \ - osapi_volume_listen \ - "${CINDER_API_SERVICE_LISTEN}" - -crudini --set $cfg \ - DEFAULT \ - osapi_volume_listen_port \ - "${CINDER_API_SERVICE_PORT}" - -crudini --set $cfg \ - DEFAULT \ - enable_v1_api \ - "false" - -crudini --set $cfg \ - DEFAULT \ - enable_v2_api \ - "true" - -echo "Starting cinder-api" -exec /usr/bin/cinder-api --config-file $cfg +exec $CMD $ARGS diff --git a/docker/common/cinder-app/cinder-backup/config-external.sh b/docker/common/cinder-app/cinder-backup/config-external.sh new file mode 100644 index 0000000000..b3d2582517 --- /dev/null +++ b/docker/common/cinder-app/cinder-backup/config-external.sh @@ -0,0 +1,9 @@ +OURCE="/opt/kolla/cinder/cinder.conf" +TARGET="/etc/cinder/cinder.conf" +OWNER="cinder" + +if [[ -f "$SOURCE" ]]; then + cp $SOURCE $TARGET + chown ${OWNER}: $TARGET + chmod 0644 $TARGET +fi diff --git a/docker/common/cinder-app/cinder-backup/config-internal.sh b/docker/common/cinder-app/cinder-backup/config-internal.sh new file mode 100644 index 0000000000..3227ddab29 --- /dev/null +++ b/docker/common/cinder-app/cinder-backup/config-internal.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +set -e + +. /opt/kolla/kolla-common.sh +. /opt/kolla/config-cinder.sh + +check_required_vars CINDER_BACKUP_DRIVER CINDER_BACKUP_MANAGER \ + CINDER_BACKUP_API_CLASS CINDER_BACKUP_NAME_TEMPLATE + +cfg=/etc/cinder/cinder.conf + +# volume backup configuration +crudini --set $cfg \ + DEFAULT \ + backup_driver \ + "${CINDER_BACKUP_DRIVER}" +crudini --set $cfg \ + DEFAULT \ + backup_topic \ + "cinder-backup" +crudini --set $cfg \ + DEFAULT \ + backup_manager \ + "${CINDER_BACKUP_MANAGER}" +crudini --set $cfg \ + DEFAULT \ + backup_api_class \ + "${CINDER_BACKUP_API_CLASS}" +crudini --set $cfg \ + DEFAULT \ + backup_name_template \ + "${CINDER_BACKUP_NAME_TEMPLATE}" + +# https://bugs.launchpad.net/kolla/+bug/1461635 +# Cinder requires mounting /dev in the cinder-volume, nova-compute, +# and libvirt containers. If /dev/pts/ptmx does not have proper permissions +# on the host, then libvirt will fail to boot an instance. +# This is a bug in Docker where it is not correctly mounting /dev/pts +# Tech Debt tracker: https://bugs.launchpad.net/kolla/+bug/1468962 +# **Temporary fix** +chmod 666 /dev/pts/ptmx + +echo "Starting cinder-backup" +exec /usr/bin/cinder-backup --config-file $cfg diff --git a/docker/common/cinder-app/cinder-backup/start.sh b/docker/common/cinder-app/cinder-backup/start.sh index 3227ddab29..1cc902db67 100755 --- a/docker/common/cinder-app/cinder-backup/start.sh +++ b/docker/common/cinder-app/cinder-backup/start.sh @@ -1,45 +1,14 @@ #!/bin/bash -set -e +set -o errexit -. /opt/kolla/kolla-common.sh -. /opt/kolla/config-cinder.sh +CMD="/usr/bin/cinder-backup" +ARGS="" -check_required_vars CINDER_BACKUP_DRIVER CINDER_BACKUP_MANAGER \ - CINDER_BACKUP_API_CLASS CINDER_BACKUP_NAME_TEMPLATE +# Loading common functions. +source /opt/kolla/kolla-common.sh -cfg=/etc/cinder/cinder.conf +# Config-internal script exec out of this function, it does not return here. +set_configs -# volume backup configuration -crudini --set $cfg \ - DEFAULT \ - backup_driver \ - "${CINDER_BACKUP_DRIVER}" -crudini --set $cfg \ - DEFAULT \ - backup_topic \ - "cinder-backup" -crudini --set $cfg \ - DEFAULT \ - backup_manager \ - "${CINDER_BACKUP_MANAGER}" -crudini --set $cfg \ - DEFAULT \ - backup_api_class \ - "${CINDER_BACKUP_API_CLASS}" -crudini --set $cfg \ - DEFAULT \ - backup_name_template \ - "${CINDER_BACKUP_NAME_TEMPLATE}" - -# https://bugs.launchpad.net/kolla/+bug/1461635 -# Cinder requires mounting /dev in the cinder-volume, nova-compute, -# and libvirt containers. If /dev/pts/ptmx does not have proper permissions -# on the host, then libvirt will fail to boot an instance. -# This is a bug in Docker where it is not correctly mounting /dev/pts -# Tech Debt tracker: https://bugs.launchpad.net/kolla/+bug/1468962 -# **Temporary fix** -chmod 666 /dev/pts/ptmx - -echo "Starting cinder-backup" -exec /usr/bin/cinder-backup --config-file $cfg +exec $CMD $ARGS diff --git a/docker/common/cinder-app/cinder-scheduler/config-external.sh b/docker/common/cinder-app/cinder-scheduler/config-external.sh new file mode 100644 index 0000000000..5f57ab939a --- /dev/null +++ b/docker/common/cinder-app/cinder-scheduler/config-external.sh @@ -0,0 +1,10 @@ +#!/bin/bash +SOURCE="/opt/kolla/cinder/cinder.conf" +TARGET="/etc/cinder/cinder.conf" +OWNER="cinder" + +if [[ -f "$SOURCE" ]]; then + cp $SOURCE $TARGET + chown ${OWNER}: $TARGET + chmod 0644 $TARGET +fi diff --git a/docker/common/cinder-app/cinder-scheduler/config-internal.sh b/docker/common/cinder-app/cinder-scheduler/config-internal.sh new file mode 100644 index 0000000000..54df779834 --- /dev/null +++ b/docker/common/cinder-app/cinder-scheduler/config-internal.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +set -e + +. /opt/kolla/kolla-common.sh +. /opt/kolla/config-cinder.sh + +fail_unless_db + +check_required_vars MARIADB_SERVICE_HOST DB_ROOT_PASSWORD \ + CINDER_DB_NAME CINDER_DB_USER CINDER_DB_PASSWORD \ + INIT_CINDER_DB + +cfg=/etc/cinder/cinder.conf + +if [ "${INIT_CINDER_DB}" == "true" ]; then + mysql -h ${MARIADB_SERVICE_HOST} -u root -p${DB_ROOT_PASSWORD} mysql <