-
Notifications
You must be signed in to change notification settings - Fork 907
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve quota usage for temporary resources
Cinder creates temporary resources, volumes and snapshots, during some of its operations, and these resources aren't counted towards quota usage. Cinder currently has a problem to track quota usage is when deleting temporary resources. Determining which volumes are temporary is a bit inconvenient because we have to check the migration status as well as the admin metadata, so they have been the source of several bugs, though they should be properly tracked now. For snapshots we don't have any way to track which ones are temporary, which creates some issues: - Quota sync mechanism will count them as normal snapshots. - Manually deleting temporary snapshots after an operation fails will mess the quota. - If we are using snapshots instead of clones for backups of in-use volumes the quota will be messed on completion. This patch proposes the introduction of a new field for those database resource tables where we create temporary resources: volumes and snaphots. The field will be called "use_quota" and will be set to False for temporary resources to indicate that we don't want them to be counted towards quota on deletion. Instead of using "temporary" as the field name "use_quota" was used to allow other cases that should not do quota in the future. Moving from our current mechanism to the new one is a multi-release process because we need to have backward compatibility code for rolling upgrades. This patch adds everything needed to complete the multi-release process so that anybody can submit next release patches. To do so the patch adds backward compatible code adding the feature in this release and TODO comments with the exact changes that need to be done for the next 2 releases. The removal of the compatibility code will be done in the next release, and in the one after that we'll remove the temporary metadata rows that may still exist in the database. With this new field we'll be able to make our DB queries more efficient for quota usage calculations, reduce the chances of introducing new quota usage bugs in the future, and allow users to filter in/out temporary volumes on listings. Closes-Bug: #1923828 Closes-Bug: #1923829 Closes-Bug: #1923830 Implements: blueprint temp-resources Change-Id: I98bd4d7a54906b613daaf14233d749da1e1531d5
- Loading branch information
Showing
25 changed files
with
656 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
cinder/db/sqlalchemy/migrate_repo/versions/145_add_use_quota_fields.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Copyright 2021 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. | ||
|
||
import sqlalchemy as sa | ||
|
||
|
||
def upgrade(migrate_engine): | ||
"""Update volumes and snapshots tables with use_quota field. | ||
Add use_quota field to both volumes and snapshots table to fast and easily | ||
identify resources that must be counted for quota usages. | ||
""" | ||
# Existing resources will be left with None value to allow rolling upgrades | ||
# with the online data migration pattern, since they will identify the | ||
# resources that don't have the field set/known yet. | ||
meta = sa.MetaData(bind=migrate_engine) | ||
for table_name in ('volumes', 'snapshots'): | ||
table = sa.Table(table_name, meta, autoload=True) | ||
|
||
if not hasattr(table.c, 'use_quota'): | ||
column = sa.Column('use_quota', sa.Boolean, nullable=True) | ||
table.create_column(column) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.