From 6c1fcf1f9ecf41a847f5fc78d26c7e8e791d613b Mon Sep 17 00:00:00 2001 From: okozachenko Date: Thu, 30 Jul 2020 12:58:00 +0300 Subject: [PATCH] Add mysql cluster to glance deployment Change-Id: Ia3fe4461a7e1991cadf5963664ec7efd19d2db7e --- chart/test-values.yaml | 3 ++- config/samples/operator-config.yaml | 2 ++ devstack/lib/glance | 18 ++++++------------ openstack_operator/glance.py | 12 +++++++++++- 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/chart/test-values.yaml b/chart/test-values.yaml index 1a01526a..10d7d0bd 100644 --- a/chart/test-values.yaml +++ b/chart/test-values.yaml @@ -4,8 +4,9 @@ configMap: ceilometer: dbUri: "sqlite:///:memory:" glance: - configDir: /etc/glance dataDir: /opt/stack/data/glance + mysql: + size: 10Gi horizon: hostAliases: - hostnames: diff --git a/config/samples/operator-config.yaml b/config/samples/operator-config.yaml index f4928cee..eba1a805 100644 --- a/config/samples/operator-config.yaml +++ b/config/samples/operator-config.yaml @@ -12,4 +12,6 @@ data: keystone: {} heat: {} magnum: {} + glance: + dataDir: /opt/stack/data/glance chronyd: {} diff --git a/devstack/lib/glance b/devstack/lib/glance index f4be71bd..5d786419 100644 --- a/devstack/lib/glance +++ b/devstack/lib/glance @@ -25,8 +25,10 @@ function configure_glance { sudo install -d -o $STACK_USER $GLANCE_CONF_DIR $GLANCE_METADEF_DIR # Set non-default configuration options for the API server - local dburl - dburl=`database_connection_url glance` + # Get mysql password + GLANCE_DATABASE_USER=$(get_data_from_secret glance-mysql openstack USER) + GLANCE_DATABASE_PASSWORD=$(get_data_from_secret glance-mysql openstack PASSWORD) + GLANCE_DATABASE_NAME=$(get_data_from_secret glance-mysql openstack DATABASE) # Configure multiple stores if [[ "$GLANCE_ENABLE_MULTIPLE_STORES" == "True" ]]; then @@ -39,7 +41,7 @@ function configure_glance { fi iniset $GLANCE_API_CONF DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL - iniset $GLANCE_API_CONF database connection $dburl + iniset $GLANCE_API_CONF database connection "mysql+pymysql://$GLANCE_DATABASE_USER:$GLANCE_DATABASE_PASSWORD@glance-mysql/$GLANCE_DATABASE_NAME?charset=utf8" iniset $GLANCE_API_CONF DEFAULT use_syslog $SYSLOG iniset $GLANCE_API_CONF DEFAULT image_cache_dir $GLANCE_CACHE_DIR/ iniset $GLANCE_API_CONF oslo_concurrency lock_path $GLANCE_LOCK_DIR @@ -78,11 +80,6 @@ function configure_glance { iniset $GLANCE_API_CONF cors allowed_origin "http://$SERVICE_HOST" fi - if [[ "$GLANCE_STANDALONE" == "False" ]]; then - # NOTE(danms): Do not advertise import methods if we are running in WSGI mode - iniset $GLANCE_API_CONF DEFAULT enabled_import_methods [] - fi - # No multiple stores for swift yet # Store the images in swift if enabled. if is_service_enabled s-proxy; then @@ -158,7 +155,7 @@ function configure_glance { fi } -# init_glance() - Initialize databases, etc. +# init_glance() function init_glance { # Delete existing images rm -rf $GLANCE_IMAGE_DIR @@ -166,9 +163,6 @@ function init_glance { # NOTE: Permissions here are bad but it's temporary so we don't care as much. sudo chmod -Rv 777 $DATA_DIR/glance - - # (Re)create glance database - recreate_database glance } export -f init_glance diff --git a/openstack_operator/glance.py b/openstack_operator/glance.py index 79ac16cb..b4d98271 100644 --- a/openstack_operator/glance.py +++ b/openstack_operator/glance.py @@ -19,6 +19,7 @@ the appropriate deployments, Mcrouter, pod monitors and Prometheus rules. """ +from openstack_operator import database from openstack_operator import utils @@ -29,11 +30,20 @@ def create_or_resume(name, spec, **_): start the service up for the first time. """ + # deploy mysql + if "mysql" not in spec: + database.ensure_mysql_cluster("glance", {}) + else: + database.ensure_mysql_cluster("glance", spec["mysql"]) + + # deploy memcached + utils.create_or_update('glance/memcached.yml.j2', spec=spec) + + # deploy glance api utils.create_or_update('glance/daemonset.yml.j2', name=name, spec=spec) utils.create_or_update('glance/service.yml.j2', name=name, spec=spec) - utils.create_or_update('glance/memcached.yml.j2', spec=spec) if "ingress" in spec: utils.create_or_update('glance/ingress.yml.j2', name=name, spec=spec)