Skip to content

Commit 4c977e1

Browse files
authored
Merge pull request #41 from stackhpc/upstream/yoga-2023-04-10
Synchronise yoga with upstream
2 parents 12b250b + f5b4125 commit 4c977e1

File tree

4 files changed

+63
-11
lines changed

4 files changed

+63
-11
lines changed

nova/db/main/api.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4176,6 +4176,12 @@ def _get_fk_stmts(metadata, conn, table, column, records):
41764176
fk_column = fk_table.c.id
41774177

41784178
for fk in fk_table.foreign_keys:
4179+
if table != fk.column.table:
4180+
# if the foreign key doesn't actually point to the table we're
4181+
# archiving entries from then it's not relevant; trying to
4182+
# resolve this would result in a cartesian product
4183+
continue
4184+
41794185
# We need to find the records in the referring (child) table that
41804186
# correspond to the records in our (parent) table so we can archive
41814187
# them.
@@ -4225,6 +4231,7 @@ def _get_fk_stmts(metadata, conn, table, column, records):
42254231
# deque.
42264232
fk_delete = fk_table.delete().where(fk_column.in_(fk_records))
42274233
deletes.appendleft(fk_delete)
4234+
42284235
# Repeat for any possible nested child tables.
42294236
i, d = _get_fk_stmts(metadata, conn, fk_table, fk_column, fk_records)
42304237
inserts.extendleft(i)

nova/objects/cell_mapping.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,11 +279,15 @@ def _get_by_project_id_from_db(context, project_id):
279279
# SELECT DISTINCT cell_id FROM instance_mappings \
280280
# WHERE project_id = $project_id;
281281
cell_ids = context.session.query(
282-
api_db_models.InstanceMapping.cell_id).filter_by(
283-
project_id=project_id).distinct().subquery()
282+
api_db_models.InstanceMapping.cell_id
283+
).filter_by(
284+
project_id=project_id
285+
).distinct()
284286
# SELECT cell_mappings WHERE cell_id IN ($cell_ids);
285-
return context.session.query(api_db_models.CellMapping).filter(
286-
api_db_models.CellMapping.id.in_(cell_ids)).all()
287+
return context.session.query(
288+
api_db_models.CellMapping).filter(
289+
api_db_models.CellMapping.id.in_(cell_ids)
290+
).all()
287291

288292
@classmethod
289293
def get_by_project_id(cls, context, project_id):

nova/tests/fixtures/nova.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,16 @@ def setUp(self):
904904
message='Implicit coercion of SELECT and textual SELECT .*',
905905
category=sqla_exc.SADeprecationWarning)
906906

907+
# Enable general SQLAlchemy warnings also to ensure we're not doing
908+
# silly stuff. It's possible that we'll need to filter things out here
909+
# with future SQLAlchemy versions, but that's a good thing
910+
911+
warnings.filterwarnings(
912+
'error',
913+
module='nova',
914+
category=sqla_exc.SAWarning,
915+
)
916+
907917
self.addCleanup(self._reset_warning_filters)
908918

909919
def _reset_warning_filters(self):

nova/tests/functional/regressions/test_bug_1888395.py

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,8 @@
2323
from nova.tests.functional.libvirt import base as libvirt_base
2424

2525

26-
class TestLiveMigrationWithoutMultiplePortBindings(
26+
class TestLiveMigrationWithoutMultiplePortBindingsBase(
2727
libvirt_base.ServersTestBase):
28-
"""Regression test for bug 1888395.
29-
30-
This regression test asserts that Live migration works when
31-
neutron does not support the binding-extended api extension
32-
and the legacy single port binding workflow is used.
33-
"""
3428

3529
ADMIN_API = True
3630
microversion = 'latest'
@@ -72,6 +66,16 @@ def setUp(self):
7266
'nova.tests.fixtures.libvirt.Domain.migrateToURI3',
7367
self._migrate_stub))
7468

69+
70+
class TestLiveMigrationWithoutMultiplePortBindings(
71+
TestLiveMigrationWithoutMultiplePortBindingsBase):
72+
"""Regression test for bug 1888395.
73+
74+
This regression test asserts that Live migration works when
75+
neutron does not support the binding-extended api extension
76+
and the legacy single port binding workflow is used.
77+
"""
78+
7579
def _migrate_stub(self, domain, destination, params, flags):
7680
"""Stub out migrateToURI3."""
7781

@@ -124,3 +128,30 @@ def test_live_migrate(self):
124128
server, {'OS-EXT-SRV-ATTR:host': 'end_host', 'status': 'ACTIVE'})
125129
msg = "NotImplementedError: Cannot load 'vif_type' in the base class"
126130
self.assertNotIn(msg, self.stdlog.logger.output)
131+
132+
133+
class TestLiveMigrationRollbackWithoutMultiplePortBindings(
134+
TestLiveMigrationWithoutMultiplePortBindingsBase):
135+
136+
def _migrate_stub(self, domain, destination, params, flags):
137+
source = self.computes['start_host']
138+
conn = source.driver._host.get_connection()
139+
dom = conn.lookupByUUIDString(self.server['id'])
140+
dom.fail_job()
141+
142+
def test_live_migration_rollback(self):
143+
self.server = self._create_server(
144+
host='start_host',
145+
networks=[{'port': self.neutron.port_1['id']}])
146+
147+
self.assertFalse(
148+
self.neutron_api.has_port_binding_extension(self.ctxt))
149+
# FIXME(artom) Until bug 1969980 is fixed, this will fail with a
150+
# NotImplementedError.
151+
self._live_migrate(self.server, migration_expected_state='error',
152+
server_expected_state='ERROR')
153+
server = self.api.get_server(self.server['id'])
154+
self.assertIn(
155+
"NotImplementedError: Cannot load 'vifs' in the base class",
156+
server['fault']['details']
157+
)

0 commit comments

Comments
 (0)