Bug 1126491 - openstack-db init fails with non-default service password for cinder
Summary: openstack-db init fails with non-default service password for cinder
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat OpenStack
Classification: Red Hat
Component: openstack-utils
Version: 5.0 (RHEL 7)
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ---
: 5.0 (RHEL 7)
Assignee: Pádraig Brady
QA Contact: yeylon@redhat.com
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-08-04 14:46 UTC by james labocki
Modified: 2016-04-18 06:59 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-12-16 15:22:58 UTC


Attachments (Terms of Use)

Description james labocki 2014-08-04 14:46:52 UTC
openstack-db init fails with a non-default service password because /etc/cinder/cinder.conf does not contain a mysql connection string by default. /etc/cinder/cinder.conf should either contain a default connection string (commented out) or the openstack-db --init command needs to be updated.

[root@host190 ~]# /usr/bin/openstack-db --service cinder --init --rootpw redhat --password redhat
+ systemctl --version
+ systemctl=1
+ '[' 7 -gt 0 ']'
+ case "$1" in
+ shift
+ APP=cinder
+ shift
+ '[' 5 -gt 0 ']'
+ case "$1" in
+ MODE=init
+ shift
+ '[' 4 -gt 0 ']'
+ case "$1" in
+ shift
+ MYSQL_ROOT_PW=redhat
+ shift
+ '[' 2 -gt 0 ']'
+ case "$1" in
+ shift
+ MYSQL_APP_PW=redhat
+ shift
+ '[' 0 -gt 0 ']'
+ '[' '!' init ']'
+ '[' '!' cinder ']'
+ case "$APP" in
+ '[' init = sync ']'
+ MYSQL_APP_PW_DEFAULT=cinder
+ : redhat
+ '[' cinder = glance ']'
+ '[' cinder = neutron ']'
+ APP_CONFIG=/etc/cinder/cinder.conf
+ grep -q '^#* *\(sql_\)*connection *= *mysql://' /etc/cinder/cinder.conf
+ NEW_MYSQL_INSTALL=0
+ rpm -q --whatprovides mysql-server
+ service_running mysqld
+ test 1
+ systemctl status mysqld.service
+ '[' 0 -eq 1 ']'
+ '[' '!' defined ']'
+ MYSQL_ROOT_PW_ARG=
+ '[' defined ']'
+ MYSQL_ROOT_PW_ARG=--password=redhat
+ echo 'SELECT 1;'
+ mysql -u root --password=redhat
+ echo 'Verified connectivity to MySQL.'
Verified connectivity to MySQL.
+ '[' init = init ']'
++ echo 'SELECT COUNT(*) FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME='\''cinder'\'';'
++ mysql -u root --password=redhat
++ tail -n+2
+ dbs=0
+ '[' 0 '!=' 0 ']'
++ echo 'SELECT COUNT(*) FROM mysql.user WHERE User = '\''cinder'\'';'
++ mysql -u root --password=redhat
++ tail -n+2
+ users=0
+ '[' 0 '!=' 0 ']'
+ mysql -u root --password=redhat
+ '[' init = init ']'
+ echo 'Creating '\''cinder'\'' database.'
Creating 'cinder' database.
+ cat
+ '[' init = init ']'
+ '[' redhat '!=' cinder ']'
+ echo 'Updating '\''cinder'\'' database password in /etc/cinder/cinder.conf'
Updating 'cinder' database password in /etc/cinder/cinder.conf
+ sed -i -e 's|^#* *\(\(sql_\)*connection *= *mysql://cinder\):.*@|\1:redhat@|' /etc/cinder/cinder.conf
+ echo 'Initializing the cinder database, please wait...'
Initializing the cinder database, please wait...
+ db_sync
+ db_manage sync
+ test -e /var/log/cinder/cinder-manage.log
+ chown cinder: /var/log/cinder/cinder-manage.log
+ '[' cinder = neutron ']'
+ cmd=sync
+ '[' cinder = nova ']'
+ '[' cinder = cinder ']'
+ db_cmd='db sync'
+ runuser -s /bin/sh cinder -c 'cinder-manage db sync'
2014-08-04 10:43:28.656 7928 CRITICAL cinder [-] OperationalError: (OperationalError) (1045, "Access denied for user 'cinder'@'localhost' (using password: YES)") None None

+ echo 'Error updating the database. Please see /var/log/cinder/ logs for details.'
Error updating the database. Please see /var/log/cinder/ logs for details.
+ exit 1

Comment 2 Eric Harney 2014-08-26 18:20:51 UTC
It looks like openstack-db is not handling the case where sql_connection/connection is not in cinder.conf when setting the database credentials.

Comment 3 Pádraig Brady 2014-08-26 18:42:51 UTC
Yes this was the assumption of this simplified tool.

cinder.conf has gotten out of date. Changes I suggest are:

  - Ensure all variables are (commented out) in /etc/cinder/cinder.conf
  - Ensure values from cinder-dist.conf are reflected there too
   (see how nova does this automatically in its spec file).
  - Move from the deprecated [DEFAULT]/sql_connection to
  [database]/connection.

The last point is why openstack-db uses the current mechanism of relying
on the template in $service.conf to be appropriate as at the timem of
writing not all services supported [database]/connection so it couldn't
use that unconditionally.  Now things may have progressed so that it
could assume that and thus use crudini to auto update [database]/connection
more robustly.  However the points above still stand.


Note You need to log in before you can comment on or make changes to this bug.