Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Commit

Permalink
Run migrations from only the bootstrap host
Browse files Browse the repository at this point in the history
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
  • Loading branch information
gandelman-a committed Jul 18, 2014
1 parent 884ab16 commit 0251102
Show file tree
Hide file tree
Showing 30 changed files with 70 additions and 33 deletions.
15 changes: 0 additions & 15 deletions elements/boot-stack/bin/reset-db
@@ -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
1 change: 1 addition & 0 deletions elements/ceilometer-api/element-deps
@@ -1,4 +1,5 @@
ceilometer
iptables
os-is-bootstrap-host
os-refresh-config
os-svc-install
@@ -0,0 +1,6 @@
#!/bin/bash
set -eux

if os-is-bootstrap-host ; then
ceilometer-dbsync --config-file /etc/ceilometer/ceilometer.conf
fi
@@ -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
Expand Down
1 change: 1 addition & 0 deletions elements/cinder-api/element-deps
@@ -1,4 +1,5 @@
cinder
os-is-bootstrap-host
os-refresh-config
os-svc-install
source-repositories
Expand Down
@@ -0,0 +1,6 @@
#!/bin/bash
set -eux

if os-is-bootstrap-host ; then
cinder-manage db sync
fi
@@ -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
Expand Down
1 change: 1 addition & 0 deletions elements/glance/element-deps
@@ -1,5 +1,6 @@
iptables
os-apply-config
os-is-bootstrap-host
os-refresh-config
os-svc-install
source-repositories
@@ -0,0 +1,6 @@
#!/bin/bash
set -eux

if os-is-bootstrap-host ; then
glance-manage db sync
fi
2 changes: 0 additions & 2 deletions elements/glance/os-refresh-config/post-configure.d/75-glance
@@ -1,8 +1,6 @@
#!/bin/bash
set -eu

glance-manage db_sync

os-svc-enable -n glance-api
os-svc-enable -n glance-reg

Expand Down
1 change: 1 addition & 0 deletions elements/heat-engine/element-deps
@@ -1,2 +1,3 @@
heat
os-apply-config
os-is-bootstrap-host
@@ -0,0 +1,6 @@
#!/bin/bash
set -eux

if os-is-bootstrap-host ; then
heat-manage db_sync
fi
Expand Up @@ -2,8 +2,6 @@

set -e

heat-manage db_sync

os-svc-enable -n heat-engine

os-svc-restart -n heat-engine
1 change: 1 addition & 0 deletions elements/ironic-api/element-deps
@@ -1,4 +1,5 @@
iptables
ironic
os-is-bootstrap-host
os-refresh-config
os-svc-install
@@ -0,0 +1,6 @@
#!/bin/bash
set -eux

if os-is-bootstrap-host ; then
ironic-dbsync --config-file /etc/ironic/ironic.conf
fi
@@ -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
1 change: 1 addition & 0 deletions elements/keystone/element-deps
@@ -1,5 +1,6 @@
iptables
os-apply-config
os-is-bootstrap-host
os-refresh-config
os-svc-install
source-repositories
@@ -0,0 +1,6 @@
#!/bin/bash
set -eux

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

keystone-manage db_sync

os-svc-enable -n keystone

os-svc-restart -n keystone
1 change: 1 addition & 0 deletions elements/neutron/element-deps
@@ -1,5 +1,6 @@
iptables
os-apply-config
os-is-bootstrap-host
os-refresh-config
os-svc-install
source-repositories
@@ -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
1 change: 1 addition & 0 deletions elements/nova-api/element-deps
@@ -1,3 +1,4 @@
iptables
nova
nova-novncproxy
os-is-bootstrap-host
@@ -0,0 +1,6 @@
#!/bin/bash
set -eux

if os-is-bootstrap-host ; then
nova-manage db sync
fi
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions elements/nova-baremetal/element-deps
@@ -1,4 +1,5 @@
iptables
nova-compute
os-apply-config
os-is-bootstrap-host
os-refresh-config
@@ -0,0 +1,6 @@
#!/bin/bash
set -eux

if os-is-bootstrap-host ; then
nova-baremetal-manage db sync
fi
@@ -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
1 change: 1 addition & 0 deletions elements/tuskar/element-deps
@@ -1,4 +1,5 @@
os-apply-config
os-is-bootstrap-host
os-refresh-config
os-svc-install
source-repositories
@@ -0,0 +1,6 @@
#!/bin/bash
set -eux

if os-is-bootstrap-host ; then
tuskar-dbsync --config-file /etc/tuskar/tuskar.conf
fi
@@ -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

0 comments on commit 0251102

Please sign in to comment.