Bug 1126491

Summary: openstack-db init fails with non-default service password for cinder
Product: Red Hat OpenStack Reporter: james labocki <jlabocki>
Component: openstack-utilsAssignee: Pádraig Brady <pbrady>
Status: CLOSED WONTFIX QA Contact: yeylon <yeylon>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 5.0 (RHEL 7)CC: eharney, scohen, srevivo, yeylon
Target Milestone: ---Keywords: ZStream
Target Release: 5.0 (RHEL 7)   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-12-16 15:22:58 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

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.