From ec3543a02883c3d9b288128e0a6cb941315e72cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Piliszek?= Date: Thu, 16 Jan 2020 19:58:37 +0100 Subject: [PATCH] Init Glance database only on the node with the database backend Since [1] Glance init depends on either g-api or g-reg being enabled. This broke multinode g-api deployments with singlenode database backend. This commit aligns Glance with other services w.r.t when to apply database init. [1] d8dec362baa2bf7f6ffe1c47352fdbe032eaf20a Change-Id: Idc07764d6ba3a828f19691f56c73cbe9179c2673 Closes-bug: #1860021 --- lib/glance | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/glance b/lib/glance index 740bcabf6a..b4cab2ad74 100644 --- a/lib/glance +++ b/lib/glance @@ -276,16 +276,18 @@ function init_glance { rm -rf $GLANCE_IMAGE_DIR mkdir -p $GLANCE_IMAGE_DIR - # (Re)create glance database - recreate_database glance + if is_service_enabled $DATABASE_BACKENDS; then + # (Re)create glance database + recreate_database glance - time_start "dbsync" - # Migrate glance database - $GLANCE_BIN_DIR/glance-manage --config-file $GLANCE_CONF_DIR/glance-api.conf db_sync + time_start "dbsync" + # Migrate glance database + $GLANCE_BIN_DIR/glance-manage --config-file $GLANCE_CONF_DIR/glance-api.conf db_sync - # Load metadata definitions - $GLANCE_BIN_DIR/glance-manage --config-file $GLANCE_CONF_DIR/glance-api.conf db_load_metadefs - time_stop "dbsync" + # Load metadata definitions + $GLANCE_BIN_DIR/glance-manage --config-file $GLANCE_CONF_DIR/glance-api.conf db_load_metadefs + time_stop "dbsync" + fi } # install_glanceclient() - Collect source and prepare