diff options
author | Stephen Finucane <stephenfin@redhat.com> | 2020-10-21 09:00:22 +0100 |
---|---|---|
committer | Stephen Finucane <stephenfin@redhat.com> | 2021-01-07 11:47:44 +0000 |
commit | 02d6a965881df5991b1f0d9a129dafc11ae5fae3 (patch) | |
tree | dfa80d9ae521366872d3097e249c687e8b0b4586 | |
parent | d83b02c5f6c70a5c63d8a0dbddbeed2934828cdc (diff) | |
download | nova-02d6a965881df5991b1f0d9a129dafc11ae5fae3.tar.gz |
db: Compact Rocky database migrations
Compact Rocky database migrations into a single migration,
'390_rocky.py'.
Users will now need to update to Rocky before updating to Stein or
later.
Specific changes include:
- Add index covering 'value' column of 'aggregate_metadata' table (389)
- Add 'trusted_certs' column to 'instance_extra' table (390)
When testing, the previous base version was 378. It is now 390.
Change-Id: I88a1a5928b5e971bef26fbb5db9403b494982a00
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
15 files changed, 3 insertions, 309 deletions
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/379_placeholder.py b/nova/db/sqlalchemy/migrate_repo/versions/379_placeholder.py deleted file mode 100644 index 7a93224504..0000000000 --- a/nova/db/sqlalchemy/migrate_repo/versions/379_placeholder.py +++ /dev/null @@ -1,22 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -# This is a placeholder for backports. -# Do not use this number for new work. New work starts after -# all the placeholders. -# -# See this for more information: -# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html - - -def upgrade(migrate_engine): - pass diff --git a/nova/db/sqlalchemy/migrate_repo/versions/380_placeholder.py b/nova/db/sqlalchemy/migrate_repo/versions/380_placeholder.py deleted file mode 100644 index 7a93224504..0000000000 --- a/nova/db/sqlalchemy/migrate_repo/versions/380_placeholder.py +++ /dev/null @@ -1,22 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -# This is a placeholder for backports. -# Do not use this number for new work. New work starts after -# all the placeholders. -# -# See this for more information: -# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html - - -def upgrade(migrate_engine): - pass diff --git a/nova/db/sqlalchemy/migrate_repo/versions/381_placeholder.py b/nova/db/sqlalchemy/migrate_repo/versions/381_placeholder.py deleted file mode 100644 index 7a93224504..0000000000 --- a/nova/db/sqlalchemy/migrate_repo/versions/381_placeholder.py +++ /dev/null @@ -1,22 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -# This is a placeholder for backports. -# Do not use this number for new work. New work starts after -# all the placeholders. -# -# See this for more information: -# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html - - -def upgrade(migrate_engine): - pass diff --git a/nova/db/sqlalchemy/migrate_repo/versions/382_placeholder.py b/nova/db/sqlalchemy/migrate_repo/versions/382_placeholder.py deleted file mode 100644 index 7a93224504..0000000000 --- a/nova/db/sqlalchemy/migrate_repo/versions/382_placeholder.py +++ /dev/null @@ -1,22 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -# This is a placeholder for backports. -# Do not use this number for new work. New work starts after -# all the placeholders. -# -# See this for more information: -# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html - - -def upgrade(migrate_engine): - pass diff --git a/nova/db/sqlalchemy/migrate_repo/versions/383_placeholder.py b/nova/db/sqlalchemy/migrate_repo/versions/383_placeholder.py deleted file mode 100644 index 7a93224504..0000000000 --- a/nova/db/sqlalchemy/migrate_repo/versions/383_placeholder.py +++ /dev/null @@ -1,22 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -# This is a placeholder for backports. -# Do not use this number for new work. New work starts after -# all the placeholders. -# -# See this for more information: -# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html - - -def upgrade(migrate_engine): - pass diff --git a/nova/db/sqlalchemy/migrate_repo/versions/384_placeholder.py b/nova/db/sqlalchemy/migrate_repo/versions/384_placeholder.py deleted file mode 100644 index 7a93224504..0000000000 --- a/nova/db/sqlalchemy/migrate_repo/versions/384_placeholder.py +++ /dev/null @@ -1,22 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -# This is a placeholder for backports. -# Do not use this number for new work. New work starts after -# all the placeholders. -# -# See this for more information: -# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html - - -def upgrade(migrate_engine): - pass diff --git a/nova/db/sqlalchemy/migrate_repo/versions/385_placeholder.py b/nova/db/sqlalchemy/migrate_repo/versions/385_placeholder.py deleted file mode 100644 index 7a93224504..0000000000 --- a/nova/db/sqlalchemy/migrate_repo/versions/385_placeholder.py +++ /dev/null @@ -1,22 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -# This is a placeholder for backports. -# Do not use this number for new work. New work starts after -# all the placeholders. -# -# See this for more information: -# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html - - -def upgrade(migrate_engine): - pass diff --git a/nova/db/sqlalchemy/migrate_repo/versions/386_placeholder.py b/nova/db/sqlalchemy/migrate_repo/versions/386_placeholder.py deleted file mode 100644 index 7a93224504..0000000000 --- a/nova/db/sqlalchemy/migrate_repo/versions/386_placeholder.py +++ /dev/null @@ -1,22 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -# This is a placeholder for backports. -# Do not use this number for new work. New work starts after -# all the placeholders. -# -# See this for more information: -# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html - - -def upgrade(migrate_engine): - pass diff --git a/nova/db/sqlalchemy/migrate_repo/versions/387_placeholder.py b/nova/db/sqlalchemy/migrate_repo/versions/387_placeholder.py deleted file mode 100644 index 7a93224504..0000000000 --- a/nova/db/sqlalchemy/migrate_repo/versions/387_placeholder.py +++ /dev/null @@ -1,22 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -# This is a placeholder for backports. -# Do not use this number for new work. New work starts after -# all the placeholders. -# -# See this for more information: -# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html - - -def upgrade(migrate_engine): - pass diff --git a/nova/db/sqlalchemy/migrate_repo/versions/388_placeholder.py b/nova/db/sqlalchemy/migrate_repo/versions/388_placeholder.py deleted file mode 100644 index 7a93224504..0000000000 --- a/nova/db/sqlalchemy/migrate_repo/versions/388_placeholder.py +++ /dev/null @@ -1,22 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -# This is a placeholder for backports. -# Do not use this number for new work. New work starts after -# all the placeholders. -# -# See this for more information: -# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html - - -def upgrade(migrate_engine): - pass diff --git a/nova/db/sqlalchemy/migrate_repo/versions/389_add_aggregate_metadata_index.py b/nova/db/sqlalchemy/migrate_repo/versions/389_add_aggregate_metadata_index.py deleted file mode 100644 index ebec2b9e4b..0000000000 --- a/nova/db/sqlalchemy/migrate_repo/versions/389_add_aggregate_metadata_index.py +++ /dev/null @@ -1,44 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - - -from oslo_log import log as logging -from sqlalchemy import MetaData, Table, Index - -LOG = logging.getLogger(__name__) - -INDEX_COLUMNS = ['value'] -INDEX_NAME = 'aggregate_metadata_value_idx' -TABLE_NAME = 'aggregate_metadata' - - -def _get_table_index(migrate_engine): - meta = MetaData() - meta.bind = migrate_engine - table = Table(TABLE_NAME, meta, autoload=True) - for idx in table.indexes: - if idx.columns.keys() == INDEX_COLUMNS: - break - else: - idx = None - return table, idx - - -def upgrade(migrate_engine): - table, index = _get_table_index(migrate_engine) - if index: - LOG.info('Skipped adding %s because an equivalent index' - ' already exists.', INDEX_NAME) - return - columns = [getattr(table.c, col_name) for col_name in INDEX_COLUMNS] - index = Index(INDEX_NAME, *columns) - index.create(migrate_engine) diff --git a/nova/db/sqlalchemy/migrate_repo/versions/390_add_trusted_certs.py b/nova/db/sqlalchemy/migrate_repo/versions/390_add_trusted_certs.py deleted file mode 100644 index 87273012a1..0000000000 --- a/nova/db/sqlalchemy/migrate_repo/versions/390_add_trusted_certs.py +++ /dev/null @@ -1,32 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - - -from sqlalchemy import Column -from sqlalchemy import MetaData -from sqlalchemy import Table -from sqlalchemy import Text - - -BASE_TABLE_NAME = 'instance_extra' -NEW_COLUMN_NAME = 'trusted_certs' - - -def upgrade(migrate_engine): - meta = MetaData() - meta.bind = migrate_engine - - for prefix in ('', 'shadow_'): - table = Table(prefix + BASE_TABLE_NAME, meta, autoload=True) - new_column = Column(NEW_COLUMN_NAME, Text, nullable=True) - if not hasattr(table.c, NEW_COLUMN_NAME): - table.create_column(new_column) diff --git a/nova/db/sqlalchemy/migrate_repo/versions/378_queens.py b/nova/db/sqlalchemy/migrate_repo/versions/390_rocky.py index 653a2303c8..859cec0ca0 100644 --- a/nova/db/sqlalchemy/migrate_repo/versions/378_queens.py +++ b/nova/db/sqlalchemy/migrate_repo/versions/390_rocky.py @@ -730,6 +730,7 @@ def upgrade(migrate_engine): Column('migration_context', Text, nullable=True), Column('keypairs', Text, nullable=True), Column('device_metadata', Text, nullable=True), + Column('trusted_certs', Text, nullable=True), mysql_engine='InnoDB', mysql_charset='utf8', ) @@ -1257,6 +1258,7 @@ def upgrade(migrate_engine): # aggregate_metadata Index('aggregate_metadata_key_idx', aggregate_metadata.c.key), + Index('aggregate_metadata_value_idx', aggregate_metadata.c.value), # agent_builds Index('agent_builds_hypervisor_os_arch_idx', diff --git a/nova/db/sqlalchemy/migration.py b/nova/db/sqlalchemy/migration.py index 82c51aec25..65cc52fa44 100644 --- a/nova/db/sqlalchemy/migration.py +++ b/nova/db/sqlalchemy/migration.py @@ -29,7 +29,7 @@ from nova import exception from nova.i18n import _ INIT_VERSION = {} -INIT_VERSION['main'] = 377 +INIT_VERSION['main'] = 389 INIT_VERSION['api'] = 0 _REPOSITORY = {} diff --git a/nova/tests/unit/db/test_migrations.py b/nova/tests/unit/db/test_migrations.py index 9217a07f50..2ce0487860 100644 --- a/nova/tests/unit/db/test_migrations.py +++ b/nova/tests/unit/db/test_migrations.py @@ -162,7 +162,6 @@ class NovaMigrationsCheckers(test_migrations.ModelsMigrationsSync, self.INIT_VERSION + 1, ] - queens_placeholders = list(range(379, 389)) # We forgot to add the rocky placeholder. We've also switched to 5 # placeholders per cycle since the rate of DB changes has dropped # significantly @@ -172,7 +171,6 @@ class NovaMigrationsCheckers(test_migrations.ModelsMigrationsSync, victoria_placeholders = list(range(413, 418)) return (special + - queens_placeholders + stein_placeholders + train_placeholders + ussuri_placeholders + @@ -231,16 +229,6 @@ class NovaMigrationsCheckers(test_migrations.ModelsMigrationsSync, def test_walk_versions(self): self.walk_versions(snake_walk=False, downgrade=False) - def _check_389(self, engine, data): - self.assertIndexMembers(engine, 'aggregate_metadata', - 'aggregate_metadata_value_idx', - ['value']) - - def _check_390(self, engine, data): - self.assertColumnExists(engine, 'instance_extra', 'trusted_certs') - self.assertColumnExists(engine, 'shadow_instance_extra', - 'trusted_certs') - def _check_391(self, engine, data): self.assertColumnExists(engine, 'block_device_mapping', 'volume_type') self.assertColumnExists(engine, 'shadow_block_device_mapping', |