From 1f1e2becfeecb3a7e061898890c49821eef95672 Mon Sep 17 00:00:00 2001 From: "wu.chunyang" Date: Mon, 21 Nov 2022 22:45:57 +0800 Subject: [PATCH] Using local registry in devstack. This patch runs a registry container during the installation of devstack Change-Id: I5e5a89cd9c65d1ea5b47fece985dbc044bfdec5e --- devstack/files/debs/trove | 1 + devstack/files/rpms/trove | 1 + devstack/plugin.sh | 19 +++++++++++++++++++ devstack/settings | 19 +++++++++++++++---- zuul.d/jobs.yaml | 13 +++++++++++-- 5 files changed, 47 insertions(+), 6 deletions(-) diff --git a/devstack/files/debs/trove b/devstack/files/debs/trove index 09dcee8104..43ab35595d 100644 --- a/devstack/files/debs/trove +++ b/devstack/files/debs/trove @@ -1 +1,2 @@ libxslt1-dev # testonly +docker.io diff --git a/devstack/files/rpms/trove b/devstack/files/rpms/trove index c5cbdea012..04ae78401e 100644 --- a/devstack/files/rpms/trove +++ b/devstack/files/rpms/trove @@ -1 +1,2 @@ libxslt-devel # testonly +docker \ No newline at end of file diff --git a/devstack/plugin.sh b/devstack/plugin.sh index cbcc56f65b..cd3fa562d5 100644 --- a/devstack/plugin.sh +++ b/devstack/plugin.sh @@ -274,6 +274,8 @@ function configure_trove { iniset $TROVE_GUESTAGENT_CONF mysql docker_image ${TROVE_DATABASE_IMAGE_MYSQL} iniset $TROVE_GUESTAGENT_CONF mysql backup_docker_image ${TROVE_DATABASE_BACKUP_IMAGE_MYSQL} + iniset $TROVE_GUESTAGENT_CONF mariadb docker_image ${TROVE_DATABASE_IMAGE_MARIADB} + iniset $TROVE_GUESTAGENT_CONF mariadb backup_docker_image ${TROVE_DATABASE_BACKUP_IMAGE_MARIADB} iniset $TROVE_GUESTAGENT_CONF postgresql docker_image ${TROVE_DATABASE_IMAGE_POSTGRES} iniset $TROVE_GUESTAGENT_CONF postgresql backup_docker_image ${TROVE_DATABASE_BACKUP_IMAGE_POSTGRES} @@ -501,6 +503,20 @@ function create_guest_image { fi } +function create_registry_container { + # running a docker registry container + echo "Running a docker registry container..." + container=$(sudo docker ps -a --format "{{.Names}}" --filter name=registry) + if [ -z $container ]; then + sudo docker run -d --net=host -e REGISTRY_HTTP_ADDR=0.0.0.0:4000 --restart=always -v /opt/trove_registry/:/var/lib/registry --name registry registry:2 + trove_agent_datastore_url=https://tarballs.opendev.org/openstack/trove/images/trove-datastore-registry-master.tar.gz + curl -o trove-datastore-registry-master.tar.gz $trove_agent_datastore_url + sudo tar -zxvf trove-datastore-registry-master.tar.gz -C /opt/trove_registry/ + rm -rf trove-datastore-registry-master.tar.gz + fi + iniset $TROVE_CONF DEFAULT docker_insecure_registries "$TROVE_HOST_GATEWAY:4000" +} + # Set up Trove management network and make configuration change. function config_trove_network { echo "Finalizing Neutron networking for Trove" @@ -639,6 +655,9 @@ if is_service_enabled trove; then config_mgmt_security_group config_trove_network create_guest_image + if [ "$TROVE_ENABLE_LOCAL_REGISTRY" == "True" ] ; then + create_registry_container + fi echo_summary "Starting Trove" start_trove diff --git a/devstack/settings b/devstack/settings index 7395a463fb..f2580b7a28 100644 --- a/devstack/settings +++ b/devstack/settings @@ -5,6 +5,8 @@ TROVE_DIR=${TROVE_DIR:-${DEST}/trove} TROVE_REPO=${TROVE_REPO:-${GIT_BASE}/openstack/trove.git} TROVE_BRANCH=${TROVE_BRANCH:-master} +# Default is set to False +TROVE_ENABLE_LOCAL_REGISTRY=${TROVE_ENABLE_LOCAL_REGISTRY:-False} TROVE_CLIENT_DIR=${TROVE_CLIENT_DIR:-${TROVECLIENT_DIR:-${DEST}/python-troveclient}} TROVE_CLIENT_REPO=${TROVE_CLIENT_REPO:-${TROVECLIENT_REPO:-${GIT_BASE}/openstack/python-troveclient.git}} @@ -87,7 +89,16 @@ TROVE_ENABLE_IMAGE_BUILD=${TROVE_ENABLE_IMAGE_BUILD:-"true"} TROVE_NON_DEV_IMAGE_URL=${TROVE_NON_DEV_IMAGE_URL:-""} # Customized database container images -TROVE_DATABASE_IMAGE_MYSQL=${TROVE_DATABASE_IMAGE_MYSQL:-"catalystcloud/mysql"} -TROVE_DATABASE_IMAGE_POSTGRES=${TROVE_DATABASE_IMAGE_POSTGRES:-"catalystcloud/postgres"} -TROVE_DATABASE_BACKUP_IMAGE_MYSQL=${TROVE_DATABASE_BACKUP_IMAGE_MYSQL:-"catalystcloud/db-backup-mysql:1.1.0"} -TROVE_DATABASE_BACKUP_IMAGE_POSTGRES=${TROVE_DATABASE_BACKUP_IMAGE_POSTGRES:-"catalystcloud/db-backup-postgresql:1.1.2"} +if [ "$TROVE_ENABLE_LOCAL_REGISTRY" == "True" ] ; then + TROVE_DATABASE_IMAGE_MYSQL=${TROVE_DATABASE_IMAGE_MYSQL:-"$TROVE_HOST_GATEWAY:4000/trove-datastores/mysql"} + TROVE_DATABASE_IMAGE_MARIADB=${TROVE_DATABASE_IMAGE_MARIAD:-"$TROVE_HOST_GATEWAY:4000/trove-datastores/mariadb"} + TROVE_DATABASE_IMAGE_POSTGRES=${TROVE_DATABASE_IMAGE_POSTGRES:-"$TROVE_HOST_GATEWAY:4000/trove-datastores/postgres"} + TROVE_DATABASE_BACKUP_IMAGE_MYSQL=${TROVE_DATABASE_BACKUP_IMAGE_MYSQL:-"$TROVE_HOST_GATEWAY:4000/trove-datastores/db-backup-mysql:1.1.0"} + TROVE_DATABASE_BACKUP_IMAGE_MARIADB=${TROVE_DATABASE_BACKUP_IMAGE_MARIADB:-"$TROVE_HOST_GATEWAY:4000/trove-datastores/db-backup-mariadb:1.1.0"} + TROVE_DATABASE_BACKUP_IMAGE_POSTGRES=${TROVE_DATABASE_BACKUP_IMAGE_POSTGRES:-"$TROVE_HOST_GATEWAY:4000/trove-datastores/db-backup-postgresql:1.1.2"} +else + TROVE_DATABASE_IMAGE_MYSQL=${TROVE_DATABASE_IMAGE_MYSQL:-"catalystcloud/mysql"} + TROVE_DATABASE_IMAGE_POSTGRES=${TROVE_DATABASE_IMAGE_POSTGRES:-"catalystcloud/postgres"} + TROVE_DATABASE_BACKUP_IMAGE_MYSQL=${TROVE_DATABASE_BACKUP_IMAGE_MYSQL:-"catalystcloud/db-backup-mysql:1.1.0"} + TROVE_DATABASE_BACKUP_IMAGE_POSTGRES=${TROVE_DATABASE_BACKUP_IMAGE_POSTGRES:-"catalystcloud/db-backup-postgresql:1.1.2"} +fi \ No newline at end of file diff --git a/zuul.d/jobs.yaml b/zuul.d/jobs.yaml index 032f47760f..6ea9188b31 100644 --- a/zuul.d/jobs.yaml +++ b/zuul.d/jobs.yaml @@ -46,6 +46,8 @@ Q_PLUGIN: ml2 Q_ML2_TENANT_NETWORK_TYPE: vxlan Q_ML2_PLUGIN_MECHANISM_DRIVERS: openvswitch + TROVE_ENABLE_LOCAL_REGISTRY: True + TROVE_DATASTORE_VERSION: 5.7 run: playbooks/trove-devstack-base.yaml irrelevant-files: - ^.*\.rst$ @@ -290,11 +292,17 @@ Q_PLUGIN: ml2 Q_ML2_TENANT_NETWORK_TYPE: vxlan Q_ML2_PLUGIN_MECHANISM_DRIVERS: openvswitch + TROVE_ENABLE_LOCAL_REGISTRY: True + TROVE_DATASTORE_VERSION: 5.7 devstack_local_conf: post-config: $TROVE_CONF: DEFAULT: usage_timeout: 1800 + test-config: + $TEMPEST_CONFIG: + database: + default_datastore_versions: mysql:5.7 devstack_plugins: trove: https://opendev.org/openstack/trove.git devstack_services: @@ -356,7 +364,8 @@ Q_ML2_TENANT_NETWORK_TYPE: vxlan Q_ML2_PLUGIN_MECHANISM_DRIVERS: openvswitch TROVE_DATASTORE_TYPE: postgresql - TROVE_DATASTORE_VERSION: 12.4 + TROVE_DATASTORE_VERSION: 12 + TROVE_ENABLE_LOCAL_REGISTRY: True devstack_local_conf: post-config: $TROVE_CONF: @@ -366,7 +375,7 @@ $TEMPEST_CONFIG: database: enabled_datastores: "postgresql" - default_datastore_versions: "postgresql:12.4" + default_datastore_versions: "postgresql:12" devstack_plugins: trove: https://opendev.org/openstack/trove.git devstack_services: