Merge "db: Compact Juno database migration"

This commit is contained in:
Zuul
2021-01-26 23:15:58 +00:00
committed by Gerrit Code Review
24 changed files with 71 additions and 787 deletions

View File

@@ -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 Icehouse backports.
# Do not use this number for new Juno work. New Juno work starts after
# all the placeholders.
#
# See blueprint backportable-db-migrations-juno
# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html
def upgrade(migrate_engine):
pass

View File

@@ -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 Icehouse backports.
# Do not use this number for new Juno work. New Juno work starts after
# all the placeholders.
#
# See blueprint backportable-db-migrations-juno
# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html
def upgrade(migrate_engine):
pass

View File

@@ -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 Icehouse backports.
# Do not use this number for new Juno work. New Juno work starts after
# all the placeholders.
#
# See blueprint backportable-db-migrations-juno
# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html
def upgrade(migrate_engine):
pass

View File

@@ -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 Icehouse backports.
# Do not use this number for new Juno work. New Juno work starts after
# all the placeholders.
#
# See blueprint backportable-db-migrations-juno
# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html
def upgrade(migrate_engine):
pass

View File

@@ -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 Icehouse backports.
# Do not use this number for new Juno work. New Juno work starts after
# all the placeholders.
#
# See blueprint backportable-db-migrations-juno
# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html
def upgrade(migrate_engine):
pass

View File

@@ -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 Icehouse backports.
# Do not use this number for new Juno work. New Juno work starts after
# all the placeholders.
#
# See blueprint backportable-db-migrations-juno
# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html
def upgrade(migrate_engine):
pass

View File

@@ -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 Icehouse backports.
# Do not use this number for new Juno work. New Juno work starts after
# all the placeholders.
#
# See blueprint backportable-db-migrations-juno
# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html
def upgrade(migrate_engine):
pass

View File

@@ -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 Icehouse backports.
# Do not use this number for new Juno work. New Juno work starts after
# all the placeholders.
#
# See blueprint backportable-db-migrations-juno
# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html
def upgrade(migrate_engine):
pass

View File

@@ -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 Icehouse backports.
# Do not use this number for new Juno work. New Juno work starts after
# all the placeholders.
#
# See blueprint backportable-db-migrations-juno
# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html
def upgrade(migrate_engine):
pass

View File

@@ -1,24 +0,0 @@
# All Rights Reserved.
#
# 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 MetaData, String, Table
def upgrade(migrate_engine):
meta = MetaData(bind=migrate_engine)
table = Table('volume_usage_cache', meta, autoload=True)
col_resource = getattr(table.c, 'user_id')
# Match the maximum length of user_id in Keystone here instead of
# assuming explicitly a single UUID length.
col_resource.alter(type=String(64))

View File

@@ -1,53 +0,0 @@
# Copyright (c) 2014 Nebula, Inc.
# All Rights Reserved
#
# 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 MetaData, Column, Table
from sqlalchemy import Boolean, Integer
from nova.db.sqlalchemy import types
def upgrade(migrate_engine):
"""Function adds network mtu, dhcp_server, and share_dhcp fields."""
meta = MetaData(bind=migrate_engine)
networks = Table('networks', meta, autoload=True)
shadow_networks = Table('shadow_networks', meta, autoload=True)
# NOTE(vish): ignore duplicate runs of upgrade so this can
# be backported
mtu = Column('mtu', Integer)
dhcp_server = Column('dhcp_server', types.IPAddress)
enable_dhcp = Column('enable_dhcp', Boolean, default=True)
share_address = Column('share_address', Boolean, default=False)
if not hasattr(networks.c, 'mtu'):
networks.create_column(mtu)
if not hasattr(networks.c, 'dhcp_server'):
networks.create_column(dhcp_server)
if not hasattr(networks.c, 'enable_dhcp'):
networks.create_column(enable_dhcp)
if not hasattr(networks.c, 'share_address'):
networks.create_column(share_address)
if not hasattr(shadow_networks.c, 'mtu'):
shadow_networks.create_column(mtu.copy())
if not hasattr(shadow_networks.c, 'dhcp_server'):
shadow_networks.create_column(dhcp_server.copy())
if not hasattr(shadow_networks.c, 'enable_dhcp'):
shadow_networks.create_column(enable_dhcp.copy())
if not hasattr(shadow_networks.c, 'share_address'):
shadow_networks.create_column(share_address.copy())

View File

@@ -1,30 +0,0 @@
# Copyright 2014 OpenStack Foundation
# All Rights Reserved
#
# 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 migrate.changeset.constraint import ForeignKeyConstraint
from sqlalchemy import MetaData, Table
def upgrade(migrate_engine):
"""Add missing foreign key constraint on pci_devices.compute_node_id."""
meta = MetaData(bind=migrate_engine)
pci_devices = Table('pci_devices', meta, autoload=True)
compute_nodes = Table('compute_nodes', meta, autoload=True)
fkey = ForeignKeyConstraint(columns=[pci_devices.c.compute_node_id],
refcolumns=[compute_nodes.c.id])
fkey.create()

View File

@@ -1,48 +0,0 @@
CREATE TABLE pci_devices_new (
created_at DATETIME,
updated_at DATETIME,
deleted_at DATETIME,
deleted INTEGER,
id INTEGER NOT NULL,
compute_node_id INTEGER NOT NULL,
address VARCHAR(12) NOT NULL,
vendor_id VARCHAR(4) NOT NULL,
product_id VARCHAR(4) NOT NULL,
dev_type VARCHAR(8) NOT NULL,
dev_id VARCHAR(255),
label VARCHAR(255) NOT NULL,
status VARCHAR(36) NOT NULL,
extra_info TEXT,
instance_uuid VARCHAR(36),
PRIMARY KEY (id),
FOREIGN KEY (compute_node_id) REFERENCES compute_nodes(id),
CONSTRAINT uniq_pci_devices0compute_node_id0address0deleted UNIQUE (compute_node_id, address, deleted)
);
INSERT INTO pci_devices_new
SELECT created_at,
updated_at,
deleted_at,
deleted,
id,
compute_node_id,
address,
vendor_id,
product_id,
dev_type,
dev_id,
label,
status,
extra_info,
instance_uuid
FROM pci_devices;
DROP TABLE pci_devices;
ALTER TABLE pci_devices_new RENAME TO pci_devices;
CREATE INDEX ix_pci_devices_compute_node_id_deleted
ON pci_devices (compute_node_id, deleted);
CREATE INDEX ix_pci_devices_instance_uuid_deleted
ON pci_devices (instance_uuid, deleted);

View File

@@ -1,30 +0,0 @@
# Copyright 2014 OpenStack Foundation
# All Rights Reserved
#
# 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 MetaData, Table
def upgrade(migrate_engine):
meta = MetaData(bind=migrate_engine)
quota_usages = Table('quota_usages', meta, autoload=True)
quota_usages.c.resource.alter(nullable=False)
pci_devices = Table('pci_devices', meta, autoload=True)
pci_devices.c.deleted.alter(nullable=True)
pci_devices.c.product_id.alter(nullable=False)
pci_devices.c.vendor_id.alter(nullable=False)
pci_devices.c.dev_type.alter(nullable=False)

View File

@@ -1,43 +0,0 @@
# All Rights Reserved.
#
# 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 Index, MetaData, Table
LOG = logging.getLogger(__name__)
def _get_deleted_expire_index(table):
members = sorted(['deleted', 'expire'])
for idx in table.indexes:
if sorted(idx.columns.keys()) == members:
return idx
def upgrade(migrate_engine):
meta = MetaData()
meta.bind = migrate_engine
reservations = Table('reservations', meta, autoload=True)
if _get_deleted_expire_index(reservations):
LOG.info('Skipped adding reservations_deleted_expire_idx '
'because an equivalent index already exists.')
return
# Based on expire_reservations query
# from: nova/db/sqlalchemy/api.py
index = Index('reservations_deleted_expire_idx',
reservations.c.deleted, reservations.c.expire)
index.create(migrate_engine)

View File

@@ -1,31 +0,0 @@
# Copyright 2014 OpenStack Foundation
# All Rights Reserved
#
# 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 MetaData, Table
INDEX_NAME = 'block_device_mapping_instance_uuid_virtual_name_device_name_idx'
def upgrade(migrate_engine):
"""Remove duplicate index from block_device_mapping table."""
meta = MetaData(bind=migrate_engine)
bdm = Table('block_device_mapping', meta, autoload=True)
for index in bdm.indexes:
if index.name == INDEX_NAME:
index.drop()

View File

@@ -1,31 +0,0 @@
# Copyright 2014 Red Hat, Inc.
# All Rights Reserved
#
# 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 MetaData, Table
def upgrade(migrate_engine):
"""Remove the instance_group_metadata table."""
meta = MetaData(bind=migrate_engine)
if migrate_engine.has_table('instance_group_metadata'):
group_metadata = Table('instance_group_metadata', meta, autoload=True)
group_metadata.drop()
if migrate_engine.has_table('shadow_instance_group_metadata'):
shadow_group_metadata = Table('shadow_instance_group_metadata', meta,
autoload=True)
shadow_group_metadata.drop()

View File

@@ -1,30 +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
def upgrade(migrate_engine):
meta = MetaData()
meta.bind = migrate_engine
compute_nodes = Table('compute_nodes', meta, autoload=True)
shadow_compute_nodes = Table('shadow_compute_nodes', meta, autoload=True)
numa_topology = Column('numa_topology', Text, nullable=True)
shadow_numa_topology = Column('numa_topology', Text, nullable=True)
compute_nodes.create_column(numa_topology)
shadow_compute_nodes.create_column(shadow_numa_topology)

View File

@@ -1,60 +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 migrate import ForeignKeyConstraint
from sqlalchemy import Column
from sqlalchemy import DateTime
from sqlalchemy import Index
from sqlalchemy import Integer
from sqlalchemy import MetaData
from sqlalchemy import String
from sqlalchemy import Table
from sqlalchemy import Text
def upgrade(migrate_engine):
meta = MetaData()
meta.bind = migrate_engine
columns = [
(('created_at', DateTime), {}),
(('updated_at', DateTime), {}),
(('deleted_at', DateTime), {}),
(('deleted', Integer), {}),
(('id', Integer), dict(primary_key=True, nullable=False)),
(('instance_uuid', String(length=36)), dict(nullable=False)),
(('numa_topology', Text), dict(nullable=True)),
]
for prefix in ('', 'shadow_'):
instances = Table(prefix + 'instances', meta, autoload=True)
basename = prefix + 'instance_extra'
if migrate_engine.has_table(basename):
continue
_columns = tuple([Column(*args, **kwargs)
for args, kwargs in columns])
table = Table(basename, meta, *_columns, mysql_engine='InnoDB',
mysql_charset='utf8')
table.create()
# Index
instance_uuid_index = Index(basename + '_idx',
table.c.instance_uuid)
instance_uuid_index.create(migrate_engine)
# Foreign key
if not prefix:
fkey_columns = [table.c.instance_uuid]
fkey_refcolumns = [instances.c.uuid]
instance_fkey = ForeignKeyConstraint(
columns=fkey_columns, refcolumns=fkey_refcolumns)
instance_fkey.create()

View File

@@ -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 = 'pci_requests'
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)

View File

@@ -1,35 +0,0 @@
# Copyright (c) 2014 Cisco Systems, Inc.
# All Rights Reserved.
#
# 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 String
from sqlalchemy import Table
def upgrade(engine):
"""Function adds request_id field."""
meta = MetaData(bind=engine)
pci_devices = Table('pci_devices', meta, autoload=True)
shadow_pci_devices = Table('shadow_pci_devices', meta, autoload=True)
request_id = Column('request_id', String(36), nullable=True)
if not hasattr(pci_devices.c, 'request_id'):
pci_devices.create_column(request_id)
if not hasattr(shadow_pci_devices.c, 'request_id'):
shadow_pci_devices.create_column(request_id.copy())

View File

@@ -21,6 +21,8 @@ from sqlalchemy import ForeignKey, Index, Integer, MetaData, String, Table
from sqlalchemy import Text
from sqlalchemy.types import NullType
from nova.db.sqlalchemy import types
LOG = logging.getLogger(__name__)
@@ -259,6 +261,7 @@ def upgrade(migrate_engine):
Column('metrics', Text, nullable=True),
Column('extra_resources', Text, nullable=True),
Column('stats', Text, default='{}'),
Column('numa_topology', Text, nullable=True),
mysql_engine='InnoDB',
mysql_charset='utf8'
)
@@ -411,20 +414,6 @@ def upgrade(migrate_engine):
mysql_charset='utf8',
)
group_metadata = Table('instance_group_metadata', meta,
Column('created_at', DateTime),
Column('updated_at', DateTime),
Column('deleted_at', DateTime),
Column('deleted', Integer),
Column('id', Integer, primary_key=True, nullable=False),
Column('key', String(length=255)),
Column('value', String(length=255)),
Column('group_id', Integer, ForeignKey('instance_groups.id'),
nullable=False),
mysql_engine='InnoDB',
mysql_charset='utf8',
)
group_policy = Table('instance_group_policy', meta,
Column('created_at', DateTime),
Column('updated_at', DateTime),
@@ -635,6 +624,19 @@ def upgrade(migrate_engine):
mysql_charset='utf8',
)
instance_extra = Table('instance_extra', meta,
Column('created_at', DateTime),
Column('updated_at', DateTime),
Column('deleted_at', DateTime),
Column('deleted', Integer),
Column('id', Integer, primary_key=True, nullable=False),
Column('instance_uuid', String(length=36), nullable=False),
Column('numa_topology', Text, nullable=True),
Column('pci_requests', Text, nullable=True),
mysql_engine='InnoDB',
mysql_charset='utf8',
)
iscsi_targets = Table('iscsi_targets', meta,
Column('created_at', DateTime),
Column('updated_at', DateTime),
@@ -714,6 +716,13 @@ def upgrade(migrate_engine):
Column('priority', Integer),
Column('rxtx_base', Integer),
Column('deleted', Integer),
Column('mtu', Integer),
Column('dhcp_server', types.IPAddress),
# NOTE(stephenfin): These were originally added by sqlalchemy-migrate
# which did not generate the constraints
Column('enable_dhcp', Boolean(create_constraint=False), default=True),
Column(
'share_address', Boolean(create_constraint=False), default=False),
UniqueConstraint('vlan', 'deleted', name='uniq_networks0vlan0deleted'),
mysql_engine='InnoDB',
mysql_charset='utf8'
@@ -735,6 +744,7 @@ def upgrade(migrate_engine):
Column('status', String(36), nullable=False),
Column('extra_info', Text, nullable=True),
Column('instance_uuid', String(36), nullable=True),
Column('request_id', String(36), nullable=True),
Index('ix_pci_devices_compute_node_id_deleted',
'compute_node_id', 'deleted'),
Index('ix_pci_devices_instance_uuid_deleted',
@@ -1078,8 +1088,8 @@ def upgrade(migrate_engine):
instance_faults, instance_id_mappings, instance_info_caches,
instance_metadata, instance_system_metadata,
instance_type_extra_specs, instance_type_projects,
instance_actions, instance_actions_events,
groups, group_metadata, group_policy, group_member,
instance_actions, instance_actions_events, instance_extra,
groups, group_policy, group_member,
iscsi_targets, key_pairs, migrations, networks,
pci_devices, provider_fw_rules, quota_classes, quota_usages,
quotas, project_user_quotas,
@@ -1140,16 +1150,6 @@ def upgrade(migrate_engine):
block_device_mapping.c.instance_uuid,
block_device_mapping.c.device_name),
# NOTE(dprince): This is now a duplicate index on MySQL and needs to
# be removed there. We leave it here so the Index ordering
# matches on schema diffs (for MySQL).
# See Havana migration 186_new_bdm_format where we dropped the
# virtual_name column.
# IceHouse fix is here: https://bugs.launchpad.net/nova/+bug/1265839
Index(
'block_device_mapping_instance_uuid_virtual_name_device_name_idx',
block_device_mapping.c.instance_uuid,
block_device_mapping.c.device_name),
Index('block_device_mapping_instance_uuid_volume_id_idx',
block_device_mapping.c.instance_uuid,
block_device_mapping.c.volume_id),
@@ -1192,9 +1192,6 @@ def upgrade(migrate_engine):
Index('instance_group_member_instance_idx',
group_member.c.instance_id),
# group_metadata
Index('instance_group_metadata_key_idx', group_metadata.c.key),
# group_policy
Index('instance_group_policy_policy_idx', group_policy.c.policy),
@@ -1221,6 +1218,9 @@ def upgrade(migrate_engine):
Index('instance_uuid_idx', instance_actions.c.instance_uuid),
Index('request_id_idx', instance_actions.c.request_id),
# instance_extra
Index('instance_extra_idx', instance_extra.c.instance_uuid),
# instance_faults
Index('instance_faults_host_idx', instance_faults.c.host),
Index('instance_faults_instance_uuid_deleted_created_at_idx',
@@ -1318,14 +1318,7 @@ def upgrade(migrate_engine):
if migrate_engine.name == 'postgresql':
Index('address', fixed_ips.c.address).create()
# NOTE(dprince): PostgreSQL doesn't allow duplicate indexes
# so we skip creation of select indexes (so schemas match exactly).
POSTGRES_INDEX_SKIPS = [
# See Havana migration 186_new_bdm_format where we dropped the
# virtual_name column.
# IceHouse fix is here: https://bugs.launchpad.net/nova/+bug/1265839
'block_device_mapping_instance_uuid_virtual_name_device_name_idx'
]
POSTGRES_INDEX_SKIPS = []
MYSQL_INDEX_SKIPS = [
# we create this one manually for MySQL above
@@ -1417,7 +1410,7 @@ def upgrade(migrate_engine):
[migrations.c.instance_uuid],
[instances.c.uuid],
'fk_migrations_instance_uuid',
]
],
]
for fkey_pair in fkeys:
@@ -1434,6 +1427,17 @@ def upgrade(migrate_engine):
columns=fkey_pair[0], refcolumns=fkey_pair[1])
fkey.create()
# TODO(stephenfin): Fold these in somehow
fkey = ForeignKeyConstraint(
columns=[pci_devices.c.compute_node_id],
refcolumns=[compute_nodes.c.id])
fkey.create()
fkey = ForeignKeyConstraint(
columns=[instance_extra.c.instance_uuid],
refcolumns=[instances.c.uuid])
fkey.create()
if migrate_engine.name == 'mysql':
# In Folsom we explicitly converted migrate_version to UTF8.
migrate_engine.execute(
@@ -1444,3 +1448,30 @@ def upgrade(migrate_engine):
migrate_engine.url.database)
_create_shadow_tables(migrate_engine)
# TODO(stephenfin): Fix these various bugs in a follow-up
# 244_increase_user_id_length_volume_usage_cache; this alternation should
# apply to shadow tables also
table = Table('volume_usage_cache', meta, autoload=True)
table.c.user_id.alter(type=String(64))
# 247_nullable_mismatch; these alterations should apply to shadow tables
# also
table = Table('quota_usages', meta, autoload=True)
table.c.resource.alter(nullable=False)
table = Table('pci_devices', meta, autoload=True)
table.c.deleted.alter(nullable=True)
table.c.product_id.alter(nullable=False)
table.c.vendor_id.alter(nullable=False)
table.c.dev_type.alter(nullable=False)
# 252_add_instance_extra_table; we don't create indexes for shadow tables
# in general and these should be removed
shadow_table = Table('shadow_instance_extra', meta, autoload=True)
idx = Index('shadow_instance_extra_idx', shadow_table.c.instance_uuid)
idx.create(migrate_engine)

View File

@@ -29,7 +29,7 @@ from nova import exception
from nova.i18n import _
INIT_VERSION = {}
INIT_VERSION['main'] = 233
INIT_VERSION['main'] = 253
INIT_VERSION['api'] = 0
_REPOSITORY = {}

View File

@@ -163,11 +163,10 @@ class NovaMigrationsCheckers(test_migrations.ModelsMigrationsSync,
def _skippable_migrations(self):
special = [
234, # Icehouse
254, # Juno
272, # NOOP migration due to revert
]
icehouse_placeholders = list(range(235, 244))
juno_placeholders = list(range(255, 265))
kilo_placeholders = list(range(281, 291))
liberty_placeholders = list(range(303, 313))
@@ -185,7 +184,6 @@ class NovaMigrationsCheckers(test_migrations.ModelsMigrationsSync,
victoria_placeholders = list(range(413, 418))
return (special +
icehouse_placeholders +
juno_placeholders +
kilo_placeholders +
liberty_placeholders +
@@ -250,106 +248,6 @@ class NovaMigrationsCheckers(test_migrations.ModelsMigrationsSync,
def test_walk_versions(self):
self.walk_versions(snake_walk=False, downgrade=False)
def _check_244(self, engine, data):
volume_usage_cache = oslodbutils.get_table(
engine, 'volume_usage_cache')
self.assertEqual(64, volume_usage_cache.c.user_id.type.length)
def _pre_upgrade_245(self, engine):
# create a fake network
networks = oslodbutils.get_table(engine, 'networks')
fake_network = {'id': 1}
networks.insert().execute(fake_network)
def _check_245(self, engine, data):
networks = oslodbutils.get_table(engine, 'networks')
network = networks.select(networks.c.id == 1).execute().first()
# mtu should default to None
self.assertIsNone(network.mtu)
# dhcp_server should default to None
self.assertIsNone(network.dhcp_server)
# enable dhcp should default to true
self.assertTrue(network.enable_dhcp)
# share address should default to false
self.assertFalse(network.share_address)
def _check_246(self, engine, data):
pci_devices = oslodbutils.get_table(engine, 'pci_devices')
self.assertEqual(1, len([fk for fk in pci_devices.foreign_keys
if fk.parent.name == 'compute_node_id']))
def _check_247(self, engine, data):
quota_usages = oslodbutils.get_table(engine, 'quota_usages')
self.assertFalse(quota_usages.c.resource.nullable)
pci_devices = oslodbutils.get_table(engine, 'pci_devices')
self.assertTrue(pci_devices.c.deleted.nullable)
self.assertFalse(pci_devices.c.product_id.nullable)
self.assertFalse(pci_devices.c.vendor_id.nullable)
self.assertFalse(pci_devices.c.dev_type.nullable)
def _check_248(self, engine, data):
self.assertIndexMembers(engine, 'reservations',
'reservations_deleted_expire_idx',
['deleted', 'expire'])
def _check_249(self, engine, data):
# Assert that only one index exists that covers columns
# instance_uuid and device_name
bdm = oslodbutils.get_table(engine, 'block_device_mapping')
self.assertEqual(1, len([i for i in bdm.indexes
if [c.name for c in i.columns] ==
['instance_uuid', 'device_name']]))
def _check_250(self, engine, data):
self.assertTableNotExists(engine, 'instance_group_metadata')
self.assertTableNotExists(engine, 'shadow_instance_group_metadata')
def _check_251(self, engine, data):
self.assertColumnExists(engine, 'compute_nodes', 'numa_topology')
self.assertColumnExists(engine, 'shadow_compute_nodes',
'numa_topology')
compute_nodes = oslodbutils.get_table(engine, 'compute_nodes')
shadow_compute_nodes = oslodbutils.get_table(engine,
'shadow_compute_nodes')
self.assertIsInstance(compute_nodes.c.numa_topology.type,
sqlalchemy.types.Text)
self.assertIsInstance(shadow_compute_nodes.c.numa_topology.type,
sqlalchemy.types.Text)
def _check_252(self, engine, data):
oslodbutils.get_table(engine, 'instance_extra')
oslodbutils.get_table(engine, 'shadow_instance_extra')
self.assertIndexMembers(engine, 'instance_extra',
'instance_extra_idx',
['instance_uuid'])
def _check_253(self, engine, data):
self.assertColumnExists(engine, 'instance_extra', 'pci_requests')
self.assertColumnExists(
engine, 'shadow_instance_extra', 'pci_requests')
instance_extra = oslodbutils.get_table(engine, 'instance_extra')
shadow_instance_extra = oslodbutils.get_table(engine,
'shadow_instance_extra')
self.assertIsInstance(instance_extra.c.pci_requests.type,
sqlalchemy.types.Text)
self.assertIsInstance(shadow_instance_extra.c.pci_requests.type,
sqlalchemy.types.Text)
def _check_254(self, engine, data):
self.assertColumnExists(engine, 'pci_devices', 'request_id')
self.assertColumnExists(
engine, 'shadow_pci_devices', 'request_id')
pci_devices = oslodbutils.get_table(engine, 'pci_devices')
shadow_pci_devices = oslodbutils.get_table(
engine, 'shadow_pci_devices')
self.assertIsInstance(pci_devices.c.request_id.type,
sqlalchemy.types.String)
self.assertIsInstance(shadow_pci_devices.c.request_id.type,
sqlalchemy.types.String)
def _check_265(self, engine, data):
# Assert that only one index exists that covers columns
# host and deleted