Merge "db: Compact migrations to Train"
This commit is contained in:
commit
120fe72e26
@ -26,7 +26,7 @@ from cinder.db.sqlalchemy import api as db_api
|
|||||||
|
|
||||||
options.set_defaults(cfg.CONF)
|
options.set_defaults(cfg.CONF)
|
||||||
|
|
||||||
INIT_VERSION = 122
|
INIT_VERSION = 134
|
||||||
MIGRATE_REPO_PATH = os.path.join(
|
MIGRATE_REPO_PATH = os.path.join(
|
||||||
os.path.abspath(os.path.dirname(__file__)),
|
os.path.abspath(os.path.dirname(__file__)),
|
||||||
'sqlalchemy',
|
'sqlalchemy',
|
||||||
|
@ -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 Rocky backports.
|
|
||||||
# Do not use this number for new Stein 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
|
|
@ -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 Rocky backports.
|
|
||||||
# Do not use this number for new Stein 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
|
|
@ -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 Rocky backports.
|
|
||||||
# Do not use this number for new Stein 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
|
|
@ -1,38 +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 MetaData, String, Table
|
|
||||||
|
|
||||||
|
|
||||||
def upgrade(migrate_engine):
|
|
||||||
"""Increase the resource column size to the quota_usages table.
|
|
||||||
|
|
||||||
The resource value is constructed from (prefix + volume_type_name),
|
|
||||||
but the length of volume_type_name is limited to 255, if we add a
|
|
||||||
prefix such as 'volumes_' or 'gigabytes_' to volume_type_name it
|
|
||||||
will exceed the db length limit.
|
|
||||||
"""
|
|
||||||
# On MariaDB, max length varies depending on the version and the InnoDB
|
|
||||||
# page size [1], so it is possible to have error 1071 ('Specified key was
|
|
||||||
# too long; max key length is 767 bytes"). Since this migration is to
|
|
||||||
# resolve a corner case, deployments with those DB versions won't be
|
|
||||||
# covered.
|
|
||||||
# [1]: https://mariadb.com/kb/en/library/innodb-limitations/#page-sizes
|
|
||||||
hide_failure = migrate_engine.name.startswith('mysql')
|
|
||||||
meta = MetaData(bind=migrate_engine)
|
|
||||||
|
|
||||||
quota_usages = Table('quota_usages', meta, autoload=True)
|
|
||||||
try:
|
|
||||||
quota_usages.c.resource.alter(type=String(300))
|
|
||||||
except Exception:
|
|
||||||
if not hide_failure:
|
|
||||||
raise
|
|
@ -1,34 +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 Boolean, Column, MetaData, Table, String
|
|
||||||
|
|
||||||
|
|
||||||
def upgrade(migrate_engine):
|
|
||||||
"""Add columns to the transfers table.
|
|
||||||
|
|
||||||
Add source_project_id, destination_project_id and accepted columns to the
|
|
||||||
transfers table to improve volume transfer records.
|
|
||||||
"""
|
|
||||||
meta = MetaData(bind=migrate_engine)
|
|
||||||
transfers = Table('transfers', meta, autoload=True)
|
|
||||||
|
|
||||||
if not hasattr(transfers.c, 'source_project_id'):
|
|
||||||
transfers.create_column(Column('source_project_id', String(255),
|
|
||||||
nullable=True))
|
|
||||||
|
|
||||||
if not hasattr(transfers.c, 'destination_project_id'):
|
|
||||||
transfers.create_column(Column('destination_project_id', String(255),
|
|
||||||
nullable=True))
|
|
||||||
|
|
||||||
if not hasattr(transfers.c, 'accepted'):
|
|
||||||
transfers.create_column(Column('accepted', Boolean, default=False))
|
|
@ -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 Stein backports.
|
|
||||||
# Do not use this number for new Train 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
|
|
@ -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 Stein backports.
|
|
||||||
# Do not use this number for new Train 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
|
|
@ -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 Stein backports.
|
|
||||||
# Do not use this number for new Train 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
|
|
@ -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.
|
|
||||||
|
|
||||||
import uuid
|
|
||||||
|
|
||||||
from oslo_utils import timeutils
|
|
||||||
from sqlalchemy import MetaData, Table
|
|
||||||
|
|
||||||
from cinder.volume import volume_types
|
|
||||||
|
|
||||||
|
|
||||||
def upgrade(migrate_engine):
|
|
||||||
"""Create default volume type"""
|
|
||||||
|
|
||||||
meta = MetaData(bind=migrate_engine)
|
|
||||||
now = timeutils.utcnow()
|
|
||||||
|
|
||||||
# create a default volume type during cinder DB migration
|
|
||||||
vtypes = Table("volume_types", meta, autoload=True)
|
|
||||||
results = list(vtypes.select().where(
|
|
||||||
vtypes.c.name == volume_types.DEFAULT_VOLUME_TYPE and
|
|
||||||
vtypes.c.deleted is False).execute())
|
|
||||||
if not results:
|
|
||||||
vtype_id = str(uuid.uuid4())
|
|
||||||
volume_type_dict = {
|
|
||||||
'id': vtype_id,
|
|
||||||
'name': volume_types.DEFAULT_VOLUME_TYPE,
|
|
||||||
'description': 'Default Volume Type',
|
|
||||||
'created_at': now,
|
|
||||||
'updated_at': now,
|
|
||||||
'deleted': False,
|
|
||||||
'is_public': True,
|
|
||||||
}
|
|
||||||
vtype = vtypes.insert()
|
|
||||||
vtype.execute(volume_type_dict)
|
|
@ -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 Train backports.
|
|
||||||
# Do not use this number for new Ussuri 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
|
|
@ -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 Train backports.
|
|
||||||
# Do not use this number for new Ussuri 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
|
|
@ -23,6 +23,7 @@ from sqlalchemy import MetaData, String, Table, Text, UniqueConstraint, text
|
|||||||
from sqlalchemy.sql import expression
|
from sqlalchemy.sql import expression
|
||||||
|
|
||||||
from cinder.volume import group_types as volume_group_types
|
from cinder.volume import group_types as volume_group_types
|
||||||
|
from cinder.volume import volume_types
|
||||||
|
|
||||||
# Get default values via config. The defaults will either
|
# Get default values via config. The defaults will either
|
||||||
# come from the default values set in the quota option
|
# come from the default values set in the quota option
|
||||||
@ -524,6 +525,9 @@ def define_tables(meta):
|
|||||||
Column('crypt_hash', String(255)),
|
Column('crypt_hash', String(255)),
|
||||||
Column('expires_at', DateTime(timezone=False)),
|
Column('expires_at', DateTime(timezone=False)),
|
||||||
Column('no_snapshots', Boolean, default=False),
|
Column('no_snapshots', Boolean, default=False),
|
||||||
|
Column('source_project_id', String(255), nullable=True),
|
||||||
|
Column('destination_project_id', String(255), nullable=True),
|
||||||
|
Column('accepted', Boolean, default=False),
|
||||||
mysql_engine='InnoDB',
|
mysql_engine='InnoDB',
|
||||||
mysql_charset='utf8'
|
mysql_charset='utf8'
|
||||||
)
|
)
|
||||||
@ -904,3 +908,37 @@ def upgrade(migrate_engine):
|
|||||||
}
|
}
|
||||||
grp_spec = group_type_specs.insert()
|
grp_spec = group_type_specs.insert()
|
||||||
grp_spec.execute(group_spec_dicts)
|
grp_spec.execute(group_spec_dicts)
|
||||||
|
|
||||||
|
# Increase the resource column size to the quota_usages table.
|
||||||
|
#
|
||||||
|
# The resource value is constructed from (prefix + volume_type_name),
|
||||||
|
# but the length of volume_type_name is limited to 255, if we add a
|
||||||
|
# prefix such as 'volumes_' or 'gigabytes_' to volume_type_name it
|
||||||
|
# will exceed the db length limit.
|
||||||
|
|
||||||
|
quota_usages = Table('quota_usages', meta, autoload=True)
|
||||||
|
try:
|
||||||
|
quota_usages.c.resource.alter(type=String(300))
|
||||||
|
except Exception:
|
||||||
|
# On MariaDB, max length varies depending on the version and the InnoDB
|
||||||
|
# page size [1], so it is possible to have error 1071 ('Specified key
|
||||||
|
# was too long; max key length is 767 bytes"). Since this migration is
|
||||||
|
# to resolve a corner case, deployments with those DB versions won't be
|
||||||
|
# covered.
|
||||||
|
# [1]: https://mariadb.com/kb/en/library/innodb-limitations/#page-sizes
|
||||||
|
if not migrate_engine.name.startswith('mysql'):
|
||||||
|
raise
|
||||||
|
|
||||||
|
# Create default volume type
|
||||||
|
vol_types = Table("volume_types", meta, autoload=True)
|
||||||
|
volume_type_dict = {
|
||||||
|
'id': str(uuid.uuid4()),
|
||||||
|
'name': volume_types.DEFAULT_VOLUME_TYPE,
|
||||||
|
'description': 'Default Volume Type',
|
||||||
|
'created_at': now,
|
||||||
|
'updated_at': now,
|
||||||
|
'deleted': False,
|
||||||
|
'is_public': True,
|
||||||
|
}
|
||||||
|
vol_type = vol_types.insert()
|
||||||
|
vol_type.execute(volume_type_dict)
|
@ -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 Train backports.
|
|
||||||
# Do not use this number for new Ussuri 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
|
|
@ -108,12 +108,12 @@ class MigrationsMixin(test_migrations.WalkVersionsMixin):
|
|||||||
# manner is provided in Cinder's developer documentation.
|
# manner is provided in Cinder's developer documentation.
|
||||||
# Reviewers: DO NOT ALLOW THINGS TO BE ADDED HERE WITHOUT CARE
|
# Reviewers: DO NOT ALLOW THINGS TO BE ADDED HERE WITHOUT CARE
|
||||||
exceptions = [
|
exceptions = [
|
||||||
# NOTE(brinzhang): 127 changes size of quota_usage.resource
|
# NOTE(brinzhang): 135 changes size of quota_usage.resource
|
||||||
# to 300. This should be safe for the 'quota_usage' db table,
|
# to 300. This should be safe for the 'quota_usage' db table,
|
||||||
# because of the 255 is the length limit of volume_type_name,
|
# because of the 255 is the length limit of volume_type_name,
|
||||||
# it should be add the additional prefix before volume_type_name,
|
# it should be add the additional prefix before volume_type_name,
|
||||||
# which we of course allow *this* size to 300.
|
# which we of course allow *this* size to 300.
|
||||||
127,
|
135,
|
||||||
# 136 modifies the the tables having volume_type_id field to set
|
# 136 modifies the the tables having volume_type_id field to set
|
||||||
# as non nullable
|
# as non nullable
|
||||||
136,
|
136,
|
||||||
|
Loading…
Reference in New Issue
Block a user