Comment 6 for bug 1713059

Revision history for this message
Felipe Reyes (freyes) wrote : Re: [Bug 1713059] Re: nova db sync is executed when the 'connection' is not defined

On Mon, Aug 28, 2017 at 03:44:42PM -0300, Felipe Reyes wrote:
> On Mon, Aug 28, 2017 at 06:25:17PM -0000, Corey Bryant wrote:
> > Hi Felipe
> >
> > Historically we've configured OpenStack services to use sqlite at
> > install time, and it makes sense to run the db sync commands in that
> > case. However, I'm not sure why we also run the db sync commands if
> > connection isn't defined (! grep -qE "^(sql_)?connection( )?=.*"
> > /etc/nova/nova.conf).
> >
> > We do this in a number of packages so I want to figure out why we do
> > that. We do the same in cinder, panko, aodh, nova, manila, to name a
> > few.
> >
> > What we don't want to do is to run the db sync commands for non-sqlite
> > db's. If not using sqlite we leave it up to the user or config mgmt
> > tooling.
>
> gotcha, then that's what that negation is meant for, the regexp needs to be tweaked a little bit to match only when "connection is config is set, but it's value contains sqlite"

Dropping the first grep:

--- /var/lib/dpkg/info/nova-common.postinst 2017-06-19 08:12:49.000000000 +0000
+++ ./nova-common.postinst 2017-08-28 18:51:01.367912483 +0000
@@ -47,8 +47,7 @@
     chown root:root /etc/nova/rootwrap.d
     chmod 0755 /etc/nova/rootwrap.d

- if ! grep -qE "^(sql_)?connection( )?=.*" /etc/nova/nova.conf || \
- grep -qE "^(sql_)?connection.*sqlite.*" /etc/nova/nova.conf
+ if grep -qE "^(sql_)?connection.*sqlite.*" /etc/nova/nova.conf
     then
       su -s /bin/sh -c 'nova-manage db sync' nova
     fi

Connection NOT defined:

root@juju-675da2-mno-17:~# bash -ex ./nova-common.postinst
+ '[' '' = configure ']'
root@juju-675da2-mno-17:~# bash -ex ./nova-common.postinst configure
+ '[' configure = configure ']'
+ getent group nova
+ getent passwd nova
+ '[' -z '' ']'
+ chown -R nova:nova /var/lib/nova/
+ chown -R nova:nova /etc/nova
+ chown -R nova:adm /var/log/nova
+ '[' -z '' ']'
+ chown -R nova:nova /var/lib/nova/
+ chmod 0640 /etc/nova/nova.conf
+ chmod 0640 /etc/nova/api-paste.ini
+ chmod 0750 /etc/nova
+ chmod 0750 /var/log/nova
+ chown root:root /etc/nova/rootwrap.conf
+ chown root:root /etc/nova/rootwrap.d
+ chmod 0755 /etc/nova/rootwrap.d
+ grep -qE '^(sql_)?connection.*sqlite.*' /etc/nova/nova.conf
+ '[' -e /var/lib/nova/nova.sqlite ']'
+ chown nova:nova /var/lib/nova/nova.sqlite
+ chmod 0640 /var/lib/nova/nova.sqlite
root@juju-675da2-mno-17:~# grep connection /etc/nova/nova.conf

Connection defined:

root@juju-675da2-mno-17:~# bash -ex ./nova-common.postinst configure
+ '[' configure = configure ']'
+ getent group nova
+ getent passwd nova
+ '[' -z '' ']'
+ chown -R nova:nova /var/lib/nova/
+ chown -R nova:nova /etc/nova
+ chown -R nova:adm /var/log/nova
+ '[' -z '' ']'
+ chown -R nova:nova /var/lib/nova/
+ chmod 0640 /etc/nova/nova.conf
+ chmod 0640 /etc/nova/api-paste.ini
+ chmod 0750 /etc/nova
+ chmod 0750 /var/log/nova
+ chown root:root /etc/nova/rootwrap.conf
+ chown root:root /etc/nova/rootwrap.d
+ chmod 0755 /etc/nova/rootwrap.d
+ grep -qE '^(sql_)?connection.*sqlite.*' /etc/nova/nova.conf
+ '[' -e /var/lib/nova/nova.sqlite ']'
+ chown nova:nova /var/lib/nova/nova.sqlite
+ chmod 0640 /var/lib/nova/nova.sqlite
root@juju-675da2-mno-17:~# grep connection /etc/nova/nova.conf
connection = mysql://nova:XXXXXXXX@10.5.1.33/nova