Skip to content

Commit 063ef48

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Exit 1 when db sync runs before api_db sync"
2 parents 4eb32cb + e99937c commit 063ef48

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

doc/source/cli/nova-manage.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ Nova Database
5656
the cell0 database). If ``--local_cell`` is specified, then only the main
5757
database in the current cell is upgraded. The local database connection is
5858
determined by ``[database]/connection`` in the configuration file passed to
59-
nova-manage.
59+
nova-manage. This command should be run after ``nova-manage api_db sync``.
60+
61+
Returns exit code 0 if the database schema was synced successfully, or 1 if
62+
cell0 cannot be accessed.
6063

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

207+
Returns exit code 0 if the database schema was synced successfully. This
208+
command should be run before ``nova-manage db sync``.
209+
204210
.. _man-page-cells-v2:
205211

206212
Nova Cells v2

doc/source/user/upgrade.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,11 @@ same time.
6969
version of Nova, either in a venv or a separate control plane node,
7070
including all the python dependencies.
7171

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

7778
* At this point, new columns and tables may exist in the database. These
7879
DB schema changes are done in a way that both the N and N+1 release can

nova/cmd/manage.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,7 @@ def sync(self, version=None, local_cell=False):
467467
Is [api_database]/connection set in nova.conf?
468468
Is the cell0 database connection URL correct?
469469
Error: %s""") % six.text_type(e))
470+
return 1
470471
return migration.db_sync(version)
471472

472473
def version(self):

nova/tests/unit/test_nova_manage.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,8 @@ def test_sync_cell0_unknown_error(self, mock_get_by_uuid):
729729
"""Asserts that a detailed error message is given when an unknown
730730
error occurs trying to get the cell0 cell mapping.
731731
"""
732-
self.commands.sync()
732+
result = self.commands.sync()
733+
self.assertEqual(1, result)
733734
mock_get_by_uuid.assert_called_once_with(
734735
test.MatchType(context.RequestContext),
735736
objects.CellMapping.CELL0_UUID)

0 commit comments

Comments
 (0)