Fix the generated cell0 default database name

This makes the default database name for cell0 be based on the
main database name, not the api one. Before this, we would get
a database name of nova_api_cell0 by default, intead of nova_cell0.
This was confusing because cell0 has "main" schema inside, not "api"
schema.

Conflicts:
        releasenotes/notes/cells-single-migration-command-0e98d66e31e02a50.yaml
        releasenotes/notes/ocata-requires-cellv2-96bd243be874d77f.yaml

NOTE(mriedem): The conflict is due to commit
7c7686366b not being in Newton.
The change from that commit is left here as it does provide
more useful information about the cell0 mapping and is
relevant to this bug fix. The ocata-requires-cellsv2 release
note from master is deleted in this cherry pick as it's
not relevant to Newton since cells v2 is optional in Newton.

Closes-Bug: #1656673
Depends-On: I4e7f6c5eaa068c98e5c4ef3feaee50d8e4f5d484
Depends-On: Ifdcd6a572dc0b42ba852241e22f6713cd2b084b0
Change-Id: I86797785f76c2c927a4db8fef72b8f8d986af6b9
(cherry picked from commit b28202fb52)
This commit is contained in:
Dan Smith 2017-01-15 10:52:36 -08:00 committed by Matt Riedemann
parent a8cd60f7a0
commit f9a3c3fcff
4 changed files with 26 additions and 11 deletions

View File

@ -1257,7 +1257,7 @@ class CellV2Commands(object):
metavar='<database_connection>',
help='The database connection url for cell0. '
'This is optional. If not provided, a standard database '
'connection will be used based on the API database connection '
'connection will be used based on the main database connection '
'from the Nova configuration.'
)
def map_cell0(self, database_connection=None):
@ -1272,11 +1272,11 @@ class CellV2Commands(object):
"""
def cell0_default_connection():
# If no database connection is provided one is generated
# based on the API database connection url.
# based on the database connection url.
# The cell0 database will use the same database scheme and
# netloc as the API database, with a related path.
# netloc as the main database, with a related path.
scheme, netloc, path, query, fragment = \
urlparse.urlsplit(CONF.api_database.connection)
urlparse.urlsplit(CONF.database.connection)
root, ext = os.path.splitext(path)
path = root + "_cell0" + ext
return urlparse.urlunsplit((scheme, netloc, path, query,

View File

@ -1114,22 +1114,22 @@ class CellV2CommandsTestCase(test.TestCase):
def test_map_cell0_default_database(self):
CONF.set_default('connection',
'fake://netloc/nova_api',
group='api_database')
'fake://netloc/nova',
group='database')
ctxt = context.RequestContext()
self.commands.map_cell0()
cell_mapping = objects.CellMapping.get_by_uuid(ctxt,
objects.CellMapping.CELL0_UUID)
self.assertEqual('cell0', cell_mapping.name)
self.assertEqual('none:///', cell_mapping.transport_url)
self.assertEqual('fake://netloc/nova_api_cell0',
self.assertEqual('fake://netloc/nova_cell0',
cell_mapping.database_connection)
def _test_migrate_simple_command(self, cell0_sync_fail=False):
ctxt = context.RequestContext()
CONF.set_default('connection',
'fake://netloc/nova_api',
group='api_database')
'fake://netloc/nova',
group='database')
values = {
'vcpus': 4,
'memory_mb': 4096,
@ -1168,7 +1168,7 @@ class CellV2CommandsTestCase(test.TestCase):
objects.CellMapping.CELL0_UUID)
self.assertEqual('cell0', cell_mapping.name)
self.assertEqual('none:///', cell_mapping.transport_url)
self.assertEqual('fake://netloc/nova_api_cell0',
self.assertEqual('fake://netloc/nova_cell0',
cell_mapping.database_connection)
# Verify the cell mapping

View File

@ -10,4 +10,9 @@ upgrade:
The new command is
"nova-manage cell_v2 simple_cell_setup --transport_url <transport_url>"
where transport_url is the connection information for the current message
queue used by Nova.
queue used by Nova. Operators must create a new database for cell0 before
running `cell_v2 simple_cell_setup`. The simple cell setup command expects
the name of the cell0 database to be `<main database name>_cell0` as it
will create a cell mapping for cell0 based on the main database connection,
sync the cell0 database, and associate existing hosts and instances with
the single cell.

View File

@ -0,0 +1,10 @@
---
fixes:
- |
The ``nova-manage cell_v2 simple_cell_setup`` command now creates the
default cell0 database connection using the ``[database]`` connection
configuration option rather than the ``[api_database]`` connection. The
cell0 database schema is the `main` database, i.e. the `instances` table,
rather than the `api` database schema. In other words, the cell0 database
would be called something like ``nova_cell0`` rather than
``nova_api_cell0``.