Skip to content

Commit

Permalink
Merge "Exit 1 when db sync runs before api_db sync"
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and openstack-gerrit committed Jul 20, 2019
2 parents 4eb32cb + e99937c commit 063ef48
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
8 changes: 7 additions & 1 deletion doc/source/cli/nova-manage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ Nova Database
the cell0 database). If ``--local_cell`` is specified, then only the main
database in the current cell is upgraded. The local database connection is
determined by ``[database]/connection`` in the configuration file passed to
nova-manage.
nova-manage. This command should be run after ``nova-manage api_db sync``.

Returns exit code 0 if the database schema was synced successfully, or 1 if
cell0 cannot be accessed.

``nova-manage db archive_deleted_rows [--max_rows <number>] [--verbose] [--until-complete] [--before <date>] [--purge]``
Move deleted rows from production tables to shadow tables. Note that the
Expand Down Expand Up @@ -201,6 +204,9 @@ Nova API Database
optional placement database if ``[placement_database]/connection`` is
configured.

Returns exit code 0 if the database schema was synced successfully. This
command should be run before ``nova-manage db sync``.

.. _man-page-cells-v2:

Nova Cells v2
Expand Down
9 changes: 5 additions & 4 deletions doc/source/user/upgrade.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,11 @@ same time.
version of Nova, either in a venv or a separate control plane node,
including all the python dependencies.

* Using the newly installed nova code, run the DB sync.
(``nova-manage api_db sync``; ``nova-manage db sync``). These schema
change operations should have minimal or no effect on performance, and
should not cause any operations to fail.
* Using the newly installed nova code, run the DB sync. First run
``nova-manage api_db sync``, then ``nova-manage db sync``. In a multi-cell
environment, ``nova-manage db sync`` must currently be run in each cell.
These schema change operations should have minimal or no effect on
performance, and should not cause any operations to fail.

* At this point, new columns and tables may exist in the database. These
DB schema changes are done in a way that both the N and N+1 release can
Expand Down
1 change: 1 addition & 0 deletions nova/cmd/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ def sync(self, version=None, local_cell=False):
Is [api_database]/connection set in nova.conf?
Is the cell0 database connection URL correct?
Error: %s""") % six.text_type(e))
return 1
return migration.db_sync(version)

def version(self):
Expand Down
3 changes: 2 additions & 1 deletion nova/tests/unit/test_nova_manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,8 @@ def test_sync_cell0_unknown_error(self, mock_get_by_uuid):
"""Asserts that a detailed error message is given when an unknown
error occurs trying to get the cell0 cell mapping.
"""
self.commands.sync()
result = self.commands.sync()
self.assertEqual(1, result)
mock_get_by_uuid.assert_called_once_with(
test.MatchType(context.RequestContext),
objects.CellMapping.CELL0_UUID)
Expand Down

0 comments on commit 063ef48

Please sign in to comment.