Run migrations from only the bootstrap host

This ensures database migrations only happen on one node.  It moves database
migration from post-configure.d to configure.d within individual service
elements and protects all 'db sync' call with an os-is-bootstrap-host check
until we have a better story regarding leadership checks.  Also removes all
redundant 'db sync' calls from the boot-stack element (they were not actually
being run there, anyway).

Change-Id: Idf3c642614699cf3f79aefd7434b3eb4983df1ae
Closes-bug: #1339047
This commit is contained in:
Adam Gandelman 2014-07-11 11:32:52 -07:00
parent 884ab16968
commit 025110241e
30 changed files with 70 additions and 33 deletions

View File

@ -1,49 +1,34 @@
#!/bin/bash
set -eux
RUN_DB_SYNC=${1:-""}
function run_db_sync() {
[ -n "$RUN_DB_SYNC" ]
}
db_pass=$(os-apply-config --key db-password)
PATH=/usr/local/bin:$PATH
os-db-create keystone keystone $db_pass
run_db_sync && keystone-manage db_sync
if which cinder-manage 1>/dev/null 2>&1; then
os-db-create cinder cinder $db_pass
run_db_sync && cinder-manage db sync
fi
if which ironic-dbsync 1>/dev/null 2>&1; then
os-db-create ironic ironic $db_pass
run_db_sync && ironic-dbsync --config-file /etc/ironic/ironic.conf
fi
if which tuskar-dbsync 1>/dev/null 2>&1; then
os-db-create tuskar tuskar $db_pass
run_db_sync && tuskar-dbsync --config-file /etc/tuskar/tuskar.conf
fi
if which ceilometer-dbsync 1>/dev/null 2>&1; then
os-db-create ceilometer ceilometer $db_pass
run_db_sync && ceilometer-dbsync --config-file /etc/ceilometer/ceilometer.conf
fi
os-db-create nova nova $db_pass
run_db_sync && nova-manage db sync
os-db-create nova_bm nova $db_pass
run_db_sync && nova-baremetal-manage db sync
os-db-create glance glance $db_pass
run_db_sync && glance-manage db_sync
os-db-create heat heat $db_pass
run_db_sync && heat-manage db_sync
os-db-create ovs_neutron neutron $db_pass
neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade head

View File

@ -1,4 +1,5 @@
ceilometer
iptables
os-is-bootstrap-host
os-refresh-config
os-svc-install

View File

@ -0,0 +1,6 @@
#!/bin/bash
set -eux
if os-is-bootstrap-host ; then
ceilometer-dbsync --config-file /etc/ceilometer/ceilometer.conf
fi

View File

@ -1,8 +1,6 @@
#!/bin/bash
set -eux
ceilometer-dbsync --config-file /etc/ceilometer/ceilometer.conf
os-svc-enable -n ceilometer-api
[ -d /mnt/state/var/lib/ceilometer ] || install -d -D -m 0770 -o ceilometer -g ceilometer /mnt/state/var/lib/ceilometer

View File

@ -1,4 +1,5 @@
cinder
os-is-bootstrap-host
os-refresh-config
os-svc-install
source-repositories

View File

@ -0,0 +1,6 @@
#!/bin/bash
set -eux
if os-is-bootstrap-host ; then
cinder-manage db sync
fi

View File

@ -1,8 +1,6 @@
#!/bin/bash
set -eu
cinder-manage db sync
os-svc-enable -n cinder-api
os-svc-enable -n cinder-scheduler
os-svc-restart -n cinder-api

View File

@ -1,5 +1,6 @@
iptables
os-apply-config
os-is-bootstrap-host
os-refresh-config
os-svc-install
source-repositories

View File

@ -0,0 +1,6 @@
#!/bin/bash
set -eux
if os-is-bootstrap-host ; then
glance-manage db sync
fi

View File

@ -1,8 +1,6 @@
#!/bin/bash
set -eu
glance-manage db_sync
os-svc-enable -n glance-api
os-svc-enable -n glance-reg

View File

@ -1,2 +1,3 @@
heat
os-apply-config
os-is-bootstrap-host

View File

@ -0,0 +1,6 @@
#!/bin/bash
set -eux
if os-is-bootstrap-host ; then
heat-manage db_sync
fi

View File

@ -2,8 +2,6 @@
set -e
heat-manage db_sync
os-svc-enable -n heat-engine
os-svc-restart -n heat-engine

View File

@ -1,4 +1,5 @@
iptables
ironic
os-is-bootstrap-host
os-refresh-config
os-svc-install

View File

@ -0,0 +1,6 @@
#!/bin/bash
set -eux
if os-is-bootstrap-host ; then
ironic-dbsync --config-file /etc/ironic/ironic.conf
fi

View File

@ -1,8 +1,6 @@
#!/bin/bash
set -eu
ironic-dbsync --config-file /etc/ironic/ironic.conf
os-svc-enable -n ironic-api
service ironic-api restart

View File

@ -1,5 +1,6 @@
iptables
os-apply-config
os-is-bootstrap-host
os-refresh-config
os-svc-install
source-repositories

View File

@ -0,0 +1,6 @@
#!/bin/bash
set -eux
if os-is-bootstrap-host ; then
keystone-manage db_sync
fi

View File

@ -1,8 +1,6 @@
#!/bin/bash
set -eux
keystone-manage db_sync
os-svc-enable -n keystone
os-svc-restart -n keystone

View File

@ -1,5 +1,6 @@
iptables
os-apply-config
os-is-bootstrap-host
os-refresh-config
os-svc-install
source-repositories

View File

@ -0,0 +1,6 @@
#!/bin/bash
set -eux
if os-is-bootstrap-host ; then
neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade head
fi

View File

@ -1,3 +1,4 @@
iptables
nova
nova-novncproxy
os-is-bootstrap-host

View File

@ -0,0 +1,6 @@
#!/bin/bash
set -eux
if os-is-bootstrap-host ; then
nova-manage db sync
fi

View File

@ -9,8 +9,6 @@ chown -R nova:nova /var/run/openstack
mkdir -p /var/run/nova
chown -R nova:nova /var/run/nova
nova-manage db sync
os-svc-enable -n nova-conductor
os-svc-enable -n nova-api
os-svc-enable -n nova-cert

View File

@ -1,4 +1,5 @@
iptables
nova-compute
os-apply-config
os-is-bootstrap-host
os-refresh-config

View File

@ -0,0 +1,6 @@
#!/bin/bash
set -eux
if os-is-bootstrap-host ; then
nova-baremetal-manage db sync
fi

View File

@ -1,8 +1,6 @@
#!/bin/bash
set -eux
nova-baremetal-manage db sync
os-svc-enable -n nova-baremetal-deploy-helper
os-svc-restart -n nova-baremetal-deploy-helper

View File

@ -1,4 +1,5 @@
os-apply-config
os-is-bootstrap-host
os-refresh-config
os-svc-install
source-repositories

View File

@ -0,0 +1,6 @@
#!/bin/bash
set -eux
if os-is-bootstrap-host ; then
tuskar-dbsync --config-file /etc/tuskar/tuskar.conf
fi

View File

@ -1,8 +1,6 @@
#!/bin/bash
set -eux
tuskar-dbsync --config-file /etc/tuskar/tuskar.conf
os-svc-enable -n tuskar-api
service tuskar-api restart