All of lore.kernel.org
 help / color / mirror / Atom feed
* [m-c-s][PATCH 1/3] postgresql: follow move to recipes-dbs done in meta-openembedded
@ 2018-03-29 19:29 Mark Asselstine
  2018-03-29 19:29 ` [m-c-s][PATCH 2/3] postgresql: update all instances of PGDATA Mark Asselstine
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Mark Asselstine @ 2018-03-29 19:29 UTC (permalink / raw)
  To: meta-virtualization

Commit 742404cc8ab0 [postgres: move to recipes-dbs] in
meta-openembedded moved the postgresql recipe to recipes-dbs. We
usually try to match the bbappend's path with that of the bb so
complete a matching move here.

Signed-off-by: Mark Asselstine <mark.asselstine@windriver.com>
---
 .../{recipes-support => recipes-dbs}/postgresql/postgresql/postgresql     | 0
 .../postgresql/postgresql/postgresql-init                                 | 0
 .../postgresql/postgresql/postgresql-init.service                         | 0
 .../{recipes-support => recipes-dbs}/postgresql/postgresql_9.%.bbappend   | 0
 4 files changed, 0 insertions(+), 0 deletions(-)
 rename meta-openstack/{recipes-support => recipes-dbs}/postgresql/postgresql/postgresql (100%)
 rename meta-openstack/{recipes-support => recipes-dbs}/postgresql/postgresql/postgresql-init (100%)
 rename meta-openstack/{recipes-support => recipes-dbs}/postgresql/postgresql/postgresql-init.service (100%)
 rename meta-openstack/{recipes-support => recipes-dbs}/postgresql/postgresql_9.%.bbappend (100%)

diff --git a/meta-openstack/recipes-support/postgresql/postgresql/postgresql b/meta-openstack/recipes-dbs/postgresql/postgresql/postgresql
similarity index 100%
rename from meta-openstack/recipes-support/postgresql/postgresql/postgresql
rename to meta-openstack/recipes-dbs/postgresql/postgresql/postgresql
diff --git a/meta-openstack/recipes-support/postgresql/postgresql/postgresql-init b/meta-openstack/recipes-dbs/postgresql/postgresql/postgresql-init
similarity index 100%
rename from meta-openstack/recipes-support/postgresql/postgresql/postgresql-init
rename to meta-openstack/recipes-dbs/postgresql/postgresql/postgresql-init
diff --git a/meta-openstack/recipes-support/postgresql/postgresql/postgresql-init.service b/meta-openstack/recipes-dbs/postgresql/postgresql/postgresql-init.service
similarity index 100%
rename from meta-openstack/recipes-support/postgresql/postgresql/postgresql-init.service
rename to meta-openstack/recipes-dbs/postgresql/postgresql/postgresql-init.service
diff --git a/meta-openstack/recipes-support/postgresql/postgresql_9.%.bbappend b/meta-openstack/recipes-dbs/postgresql/postgresql_9.%.bbappend
similarity index 100%
rename from meta-openstack/recipes-support/postgresql/postgresql_9.%.bbappend
rename to meta-openstack/recipes-dbs/postgresql/postgresql_9.%.bbappend
-- 
2.7.4



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [m-c-s][PATCH 2/3] postgresql: update all instances of PGDATA
  2018-03-29 19:29 [m-c-s][PATCH 1/3] postgresql: follow move to recipes-dbs done in meta-openembedded Mark Asselstine
@ 2018-03-29 19:29 ` Mark Asselstine
  2018-03-29 19:29 ` [m-c-s][PATCH 3/3] postgresql: don't attempt to start the DB before we setup the DB Mark Asselstine
  2018-04-04  3:24 ` [m-c-s][PATCH 1/3] postgresql: follow move to recipes-dbs done in meta-openembedded Bruce Ashfield
  2 siblings, 0 replies; 4+ messages in thread
From: Mark Asselstine @ 2018-03-29 19:29 UTC (permalink / raw)
  To: meta-virtualization

While investigating a postgresql startup issue I found we were only
updating one instance of PGDATA where several exist. We do not use
these other instances but they are files installed in the system and
should reflect our customized setting for PGDATA.

Signed-off-by: Mark Asselstine <mark.asselstine@windriver.com>
---
 meta-openstack/recipes-dbs/postgresql/postgresql_9.%.bbappend | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/meta-openstack/recipes-dbs/postgresql/postgresql_9.%.bbappend b/meta-openstack/recipes-dbs/postgresql/postgresql_9.%.bbappend
index 5b87960..1b8a952 100644
--- a/meta-openstack/recipes-dbs/postgresql/postgresql_9.%.bbappend
+++ b/meta-openstack/recipes-dbs/postgresql/postgresql_9.%.bbappend
@@ -19,7 +19,6 @@ do_install_append() {
     install -m 0755 ${WORKDIR}/postgresql-init ${D_DEST_DIR}/postgresql-init
 
     sed -e "s:%DB_DATADIR%:${DB_DATADIR}:g" -i ${D_DEST_DIR}/postgresql-init
-    sed -e "s:\(PGDATA=\).*$:\1${DB_DATADIR}:g" -i ${D}${systemd_unitdir}/system/postgresql.service
 
     sed -e "s:%DB_USER%:${DB_USER}:g" -i ${D_DEST_DIR}/postgresql-init
     sed -e "s:%DB_PASSWORD%:${DB_PASSWORD}:g" -i ${D_DEST_DIR}/postgresql-init
@@ -34,6 +33,16 @@ do_install_append() {
     PG_INIT_SERVICE_FILE=${D}${systemd_unitdir}/system/postgresql-init.service
     install -m 644 ${WORKDIR}/postgresql-init.service ${PG_INIT_SERVICE_FILE}
     sed -e "s:%SYSCONFIGDIR%:${sysconfdir}:g" -i ${PG_INIT_SERVICE_FILE}
+
+    # Update PGDATA throughout
+    files="${D}${localstatedir}/lib/${BPN}/.bash_profile"
+    files="$files ${D}${systemd_unitdir}/system/postgresql.service"
+    files="$files ${D}${bindir}/${BPN}-setup"
+    files="$files ${D}${sysconfdir}/init.d/${BPN}-server"
+    for f in $files
+    do
+        sed -e "s:\(PGDATA=\).*$:\1${DB_DATADIR}:g" -i $f
+    done
 }
 
 PACKAGES += " ${PN}-setup"
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [m-c-s][PATCH 3/3] postgresql: don't attempt to start the DB before we setup the DB
  2018-03-29 19:29 [m-c-s][PATCH 1/3] postgresql: follow move to recipes-dbs done in meta-openembedded Mark Asselstine
  2018-03-29 19:29 ` [m-c-s][PATCH 2/3] postgresql: update all instances of PGDATA Mark Asselstine
@ 2018-03-29 19:29 ` Mark Asselstine
  2018-04-04  3:24 ` [m-c-s][PATCH 1/3] postgresql: follow move to recipes-dbs done in meta-openembedded Bruce Ashfield
  2 siblings, 0 replies; 4+ messages in thread
From: Mark Asselstine @ 2018-03-29 19:29 UTC (permalink / raw)
  To: meta-virtualization

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>
---
 .../postgresql/postgresql/postgresql-init          | 36 +++++++++++++---------
 .../recipes-dbs/postgresql/postgresql_9.%.bbappend |  5 +++
 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%
 DB_PASSWORD=%DB_PASSWORD%
 DATA_DIR=%DB_DATADIR%
 
-if [ ! -e $DATA_DIR ]; then
-	mkdir -p $DATA_DIR
-	chown postgres $DATA_DIR
-fi
+initdb(){
+    if [ ! -e $DATA_DIR ]; then
+        mkdir -p $DATA_DIR
+        chown postgres $DATA_DIR
+    fi
 
-if [ -e $DATA_DIR/PG_VERSION ]; then
-    # the database has already been initialized, return
-    exit 0
-fi
+    if [ -e $DATA_DIR/PG_VERSION ]; then
+        # the database has already been initialized, return
+        exit 0
+    fi
+
+    # Create the DB
+    sudo -u postgres initdb -D $DATA_DIR
 
-# Create the DB
-sudo -u postgres initdb -D $DATA_DIR
+    # Allow readers/writers by IP
+    echo "listen_addresses = '*'" >> $DATA_DIR/postgresql.conf
+    echo "host   all   all   ${CONTROLLER_IP}/32   trust" >> $DATA_DIR/pg_hba.conf
+    echo "host   all   all   ${COMPUTE_IP}/32   trust" >> $DATA_DIR/pg_hba.conf
+    }
 
-# Allow readers/writers by IP
-echo "listen_addresses = '*'" >> $DATA_DIR/postgresql.conf
-echo "host   all   all   ${CONTROLLER_IP}/32   trust" >> $DATA_DIR/pg_hba.conf
-echo "host   all   all   ${COMPUTE_IP}/32   trust" >> $DATA_DIR/pg_hba.conf
-systemctl restart postgresql
+if [ "$1" == "initdb" ]; then
+    initdb
+    exit 0
+fi
 
 count=0
 done=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() {
     do
         sed -e "s:\(PGDATA=\).*$:\1${DB_DATADIR}:g" -i $f
     done
+
+    # Ensure DB is initialize before we attempt to start the service
+    FILE=${D}${systemd_unitdir}/system/postgresql.service
+    sed -e '/ExecStart=.*/i ExecStartPre=-${sysconfdir}/postgresql/postgresql-init initdb' -i $FILE
+    sed -e '/ExecStartPre=.*/i PermissionsStartOnly=true' -i $FILE
 }
 
 PACKAGES += " ${PN}-setup"
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [m-c-s][PATCH 1/3] postgresql: follow move to recipes-dbs done in meta-openembedded
  2018-03-29 19:29 [m-c-s][PATCH 1/3] postgresql: follow move to recipes-dbs done in meta-openembedded Mark Asselstine
  2018-03-29 19:29 ` [m-c-s][PATCH 2/3] postgresql: update all instances of PGDATA Mark Asselstine
  2018-03-29 19:29 ` [m-c-s][PATCH 3/3] postgresql: don't attempt to start the DB before we setup the DB Mark Asselstine
@ 2018-04-04  3:24 ` Bruce Ashfield
  2 siblings, 0 replies; 4+ messages in thread
From: Bruce Ashfield @ 2018-04-04  3:24 UTC (permalink / raw)
  To: Mark Asselstine; +Cc: meta-virtualization

The series has been merged.

Bruce

On Thu, Mar 29, 2018 at 3:29 PM, Mark Asselstine
<mark.asselstine@windriver.com> wrote:
> Commit 742404cc8ab0 [postgres: move to recipes-dbs] in
> meta-openembedded moved the postgresql recipe to recipes-dbs. We
> usually try to match the bbappend's path with that of the bb so
> complete a matching move here.
>
> Signed-off-by: Mark Asselstine <mark.asselstine@windriver.com>
> ---
>  .../{recipes-support => recipes-dbs}/postgresql/postgresql/postgresql     | 0
>  .../postgresql/postgresql/postgresql-init                                 | 0
>  .../postgresql/postgresql/postgresql-init.service                         | 0
>  .../{recipes-support => recipes-dbs}/postgresql/postgresql_9.%.bbappend   | 0
>  4 files changed, 0 insertions(+), 0 deletions(-)
>  rename meta-openstack/{recipes-support => recipes-dbs}/postgresql/postgresql/postgresql (100%)
>  rename meta-openstack/{recipes-support => recipes-dbs}/postgresql/postgresql/postgresql-init (100%)
>  rename meta-openstack/{recipes-support => recipes-dbs}/postgresql/postgresql/postgresql-init.service (100%)
>  rename meta-openstack/{recipes-support => recipes-dbs}/postgresql/postgresql_9.%.bbappend (100%)
>
> diff --git a/meta-openstack/recipes-support/postgresql/postgresql/postgresql b/meta-openstack/recipes-dbs/postgresql/postgresql/postgresql
> similarity index 100%
> rename from meta-openstack/recipes-support/postgresql/postgresql/postgresql
> rename to meta-openstack/recipes-dbs/postgresql/postgresql/postgresql
> diff --git a/meta-openstack/recipes-support/postgresql/postgresql/postgresql-init b/meta-openstack/recipes-dbs/postgresql/postgresql/postgresql-init
> similarity index 100%
> rename from meta-openstack/recipes-support/postgresql/postgresql/postgresql-init
> rename to meta-openstack/recipes-dbs/postgresql/postgresql/postgresql-init
> diff --git a/meta-openstack/recipes-support/postgresql/postgresql/postgresql-init.service b/meta-openstack/recipes-dbs/postgresql/postgresql/postgresql-init.service
> similarity index 100%
> rename from meta-openstack/recipes-support/postgresql/postgresql/postgresql-init.service
> rename to meta-openstack/recipes-dbs/postgresql/postgresql/postgresql-init.service
> diff --git a/meta-openstack/recipes-support/postgresql/postgresql_9.%.bbappend b/meta-openstack/recipes-dbs/postgresql/postgresql_9.%.bbappend
> similarity index 100%
> rename from meta-openstack/recipes-support/postgresql/postgresql_9.%.bbappend
> rename to meta-openstack/recipes-dbs/postgresql/postgresql_9.%.bbappend
> --
> 2.7.4
>
> --
> _______________________________________________
> meta-virtualization mailing list
> meta-virtualization@yoctoproject.org
> https://lists.yoctoproject.org/listinfo/meta-virtualization



-- 
"Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end"


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-04-04  3:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-29 19:29 [m-c-s][PATCH 1/3] postgresql: follow move to recipes-dbs done in meta-openembedded Mark Asselstine
2018-03-29 19:29 ` [m-c-s][PATCH 2/3] postgresql: update all instances of PGDATA Mark Asselstine
2018-03-29 19:29 ` [m-c-s][PATCH 3/3] postgresql: don't attempt to start the DB before we setup the DB Mark Asselstine
2018-04-04  3:24 ` [m-c-s][PATCH 1/3] postgresql: follow move to recipes-dbs done in meta-openembedded Bruce Ashfield

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.