summaryrefslogtreecommitdiffstats
path: root/meta-openstack
diff options
context:
space:
mode:
authorMark Asselstine <mark.asselstine@windriver.com>2018-03-29 15:29:13 -0400
committerBruce Ashfield <bruce.ashfield@windriver.com>2018-04-03 23:23:43 -0400
commit8aa49d991123a954b404686cead6b58dc6de9242 (patch)
tree704261b38e135fc94228d8682c95676c46cdf3b1 /meta-openstack
parent7db67a8eced8399d198bfa2cd6b9995f8842ead2 (diff)
downloadmeta-cloud-services-8aa49d991123a954b404686cead6b58dc6de9242.tar.gz
postgresql: don't attempt to start the DB before we setup the DB
When we boot the first time the postgresql service will [FAIL] and the following error is reported: pg_ctl[288]: pg_ctl: directory "/etc/postgresql/data" does not exist This is a result of the service being started before a call to postgresql's initdb is made on the PGDATA directory, usually made by the package's default 'postgresql-setup' or our 'postgresql-init' scripts. We split our 'postgresql-init' script into two, the first part which does the 'initdb' can be executed as part of the postgresql.service 'ExecStartPre' allowing the postgresql.service to not fail. The remainder of 'postgresql-init' script is executed as before, via the postgresql-init.service on first boot. This change also fixes some of the first boot startup races that was preventing some of the openstack '*-init' services which do DB configuration for openstack components from executing correctly. Signed-off-by: Mark Asselstine <mark.asselstine@windriver.com> Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
Diffstat (limited to 'meta-openstack')
-rw-r--r--meta-openstack/recipes-dbs/postgresql/postgresql/postgresql-init36
-rw-r--r--meta-openstack/recipes-dbs/postgresql/postgresql_9.%.bbappend5
2 files changed, 26 insertions, 15 deletions
diff --git a/meta-openstack/recipes-dbs/postgresql/postgresql/postgresql-init b/meta-openstack/recipes-dbs/postgresql/postgresql/postgresql-init
index cc7b13e..e1f9484 100644
--- a/meta-openstack/recipes-dbs/postgresql/postgresql/postgresql-init
+++ b/meta-openstack/recipes-dbs/postgresql/postgresql/postgresql-init
@@ -8,24 +8,30 @@ DB_USER=%DB_USER%
8DB_PASSWORD=%DB_PASSWORD% 8DB_PASSWORD=%DB_PASSWORD%
9DATA_DIR=%DB_DATADIR% 9DATA_DIR=%DB_DATADIR%
10 10
11if [ ! -e $DATA_DIR ]; then 11initdb(){
12 mkdir -p $DATA_DIR 12 if [ ! -e $DATA_DIR ]; then
13 chown postgres $DATA_DIR 13 mkdir -p $DATA_DIR
14fi 14 chown postgres $DATA_DIR
15 fi
15 16
16if [ -e $DATA_DIR/PG_VERSION ]; then 17 if [ -e $DATA_DIR/PG_VERSION ]; then
17 # the database has already been initialized, return 18 # the database has already been initialized, return
18 exit 0 19 exit 0
19fi 20 fi
21
22 # Create the DB
23 sudo -u postgres initdb -D $DATA_DIR
20 24
21# Create the DB 25 # Allow readers/writers by IP
22sudo -u postgres initdb -D $DATA_DIR 26 echo "listen_addresses = '*'" >> $DATA_DIR/postgresql.conf
27 echo "host all all ${CONTROLLER_IP}/32 trust" >> $DATA_DIR/pg_hba.conf
28 echo "host all all ${COMPUTE_IP}/32 trust" >> $DATA_DIR/pg_hba.conf
29 }
23 30
24# Allow readers/writers by IP 31if [ "$1" == "initdb" ]; then
25echo "listen_addresses = '*'" >> $DATA_DIR/postgresql.conf 32 initdb
26echo "host all all ${CONTROLLER_IP}/32 trust" >> $DATA_DIR/pg_hba.conf 33 exit 0
27echo "host all all ${COMPUTE_IP}/32 trust" >> $DATA_DIR/pg_hba.conf 34fi
28systemctl restart postgresql
29 35
30count=0 36count=0
31done=0 37done=0
diff --git a/meta-openstack/recipes-dbs/postgresql/postgresql_9.%.bbappend b/meta-openstack/recipes-dbs/postgresql/postgresql_9.%.bbappend
index 1b8a952..5bf25e1 100644
--- a/meta-openstack/recipes-dbs/postgresql/postgresql_9.%.bbappend
+++ b/meta-openstack/recipes-dbs/postgresql/postgresql_9.%.bbappend
@@ -43,6 +43,11 @@ do_install_append() {
43 do 43 do
44 sed -e "s:\(PGDATA=\).*$:\1${DB_DATADIR}:g" -i $f 44 sed -e "s:\(PGDATA=\).*$:\1${DB_DATADIR}:g" -i $f
45 done 45 done
46
47 # Ensure DB is initialize before we attempt to start the service
48 FILE=${D}${systemd_unitdir}/system/postgresql.service
49 sed -e '/ExecStart=.*/i ExecStartPre=-${sysconfdir}/postgresql/postgresql-init initdb' -i $FILE
50 sed -e '/ExecStartPre=.*/i PermissionsStartOnly=true' -i $FILE
46} 51}
47 52
48PACKAGES += " ${PN}-setup" 53PACKAGES += " ${PN}-setup"