diff --git a/nova/db/main/api.py b/nova/db/main/api.py index a89ad8125f..698866b789 100644 --- a/nova/db/main/api.py +++ b/nova/db/main/api.py @@ -4162,7 +4162,7 @@ def _get_fk_stmts(metadata, conn, table, column, records): fk_shadow_tablename = _SHADOW_TABLE_PREFIX + fk_table.name try: fk_shadow_table = schema.Table( - fk_shadow_tablename, metadata, autoload=True) + fk_shadow_tablename, metadata, autoload_with=conn) except sqla_exc.NoSuchTableError: # No corresponding shadow table; skip it. continue @@ -4257,7 +4257,8 @@ def _archive_deleted_rows_for_table(metadata, tablename, max_rows, before, rows_archived = 0 deleted_instance_uuids = [] try: - shadow_table = schema.Table(shadow_tablename, metadata, autoload=True) + shadow_table = schema.Table( + shadow_tablename, metadata, autoload_with=conn) except sqla_exc.NoSuchTableError: # No corresponding shadow table; skip it. return rows_archived, deleted_instance_uuids, {} diff --git a/nova/db/main/legacy_migrations/versions/402_train.py b/nova/db/main/legacy_migrations/versions/402_train.py index 3adaeede74..6ce9bdde17 100644 --- a/nova/db/main/legacy_migrations/versions/402_train.py +++ b/nova/db/main/legacy_migrations/versions/402_train.py @@ -63,7 +63,7 @@ def _create_shadow_tables(migrate_engine): ): continue - table = sa.Table(table_name, meta, autoload=True) + table = sa.Table(table_name, meta, autoload_with=migrate_engine) columns = [] for column in table.columns: @@ -169,13 +169,15 @@ def _create_shadow_tables(migrate_engine): # 252_add_instance_extra_table; we don't create indexes for shadow tables # in general and these should be removed - table = sa.Table('shadow_instance_extra', meta, autoload=True) + table = sa.Table( + 'shadow_instance_extra', meta, autoload_with=migrate_engine, + ) idx = sa.Index('shadow_instance_extra_idx', table.c.instance_uuid) idx.create(migrate_engine) # 373_migration_uuid; we should't create indexes for shadow tables - table = sa.Table('shadow_migrations', meta, autoload=True) + table = sa.Table('shadow_migrations', meta, autoload_with=migrate_engine) idx = sa.Index('shadow_migrations_uuid', table.c.uuid, unique=True) idx.create(migrate_engine) diff --git a/nova/tests/fixtures/nova.py b/nova/tests/fixtures/nova.py index 612269ac15..54df12ef05 100644 --- a/nova/tests/fixtures/nova.py +++ b/nova/tests/fixtures/nova.py @@ -841,12 +841,6 @@ class WarningsFixture(fixtures.Fixture): message=r'The Engine.execute\(\) method is considered legacy', category=sqla_exc.SADeprecationWarning) - warnings.filterwarnings( - 'ignore', - module='nova', - message=r'The autoload parameter is deprecated .*', - category=sqla_exc.SADeprecationWarning) - warnings.filterwarnings( 'ignore', module='nova', diff --git a/nova/tests/unit/db/main/test_api.py b/nova/tests/unit/db/main/test_api.py index 199fe99e0c..84180822d0 100644 --- a/nova/tests/unit/db/main/test_api.py +++ b/nova/tests/unit/db/main/test_api.py @@ -5714,8 +5714,10 @@ class ArchiveTestCase(test.TestCase, ModelsObjectComparatorMixin): shadow_table_name = f'shadow_{table_name}' - table = sa.Table(table_name, metadata, autoload=True) - shadow_table = sa.Table(shadow_table_name, metadata, autoload=True) + table = sa.Table(table_name, metadata, autoload_with=self.engine) + shadow_table = sa.Table( + shadow_table_name, metadata, autoload_with=self.engine, + ) columns = {c.name: c for c in table.columns} shadow_columns = {c.name: c for c in shadow_table.columns}