stein: install python3-mysqldb for sqlalchemy dialect change

At Stein, the default mysql dialect in SQLAlchemy switched back
to MySQLDB in Ubuntu; as a result the db connection URL's stored
in the nova_api database for Nova cells are stale and need to
prefixed mysql+pymysql:// to work with the pymysql dialect.

However at this point in time there is no way to update the DB
URL for Nova Cell 0.

This fix works around this problem by installing python3-mysqldb
which provides the default dialect needed when using mysql://
prefixed DB connection URI's.

Change-Id: I3f74f18f649786fefa113fc3d8fa7c24010a185d
Related-Bug: 1835037
This commit is contained in:
James Page 2019-07-23 16:47:06 +01:00
parent ee35c1319d
commit 3c806a23f6
2 changed files with 25 additions and 1 deletions

View File

@ -409,6 +409,14 @@ def determine_packages():
packages = [p for p in packages if not p.startswith('python-')]
packages.extend(PY3_PACKAGES)
packages.remove('libapache2-mod-wsgi')
if release >= 'stein':
# NOTE(jamespage):
# workaround to deal with lack of functionality to update the db
# connection for Cell 0. At stein, the default SQLAlchemy dialect
# switched to mysqldb, which requires use of mysql+pymysql:// in
# all connection strings, but there is no way to update the
# db url for cell0 as stored in the nova_api DB.
packages.append('python3-mysqldb')
return list(set(packages))

View File

@ -508,7 +508,23 @@ class NovaCCUtilsTests(CharmTestCase):
ex.remove('nova-objectstore')
ex.remove('nova-api-ec2')
self.assertEqual(sorted(ex), sorted(pkgs))
self.assertEqual(ex, pkgs)
@patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext')
def test_determine_packages_base_stein(self, subcontext):
self.relation_ids.return_value = []
self.os_release.return_value = 'stein'
self.token_cache_pkgs.return_value = []
self.enable_memcache.return_value = False
pkgs = utils.determine_packages()
ex = list(set([p for p in utils.BASE_PACKAGES + utils.BASE_SERVICES
if not p.startswith('python-')] + utils.PY3_PACKAGES))
# some packages still need to be removed
ex.remove('libapache2-mod-wsgi')
ex.remove('nova-cert')
ex.remove('nova-objectstore')
ex.remove('nova-api-ec2')
ex.append('python3-mysqldb')
self.assertEqual(sorted(ex), sorted(pkgs))
@patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext')
def test_determine_packages_serial_console(self, subcontext):