forked from openstack/cinder
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Report tri-state shared_targets for NVMe volumes
NVMe-oF drivers that share the subsystem have the same race condition issue that iSCSI volumes that share targets do. The race condition is caused by AER messages that trigger automatic rescans on the connector host side in both cases. For iSCSI we added a feature on the Open-iSCSI project that allowed disabling these scans, and added support for it in os-brick. Since manual scans is a new feature that may be missing in a host's iSCSI client, cinder has a flag in volumes to indicate when they use shared targets. Using that flag os-brick consumers can use the "guard_connection" context manager to ensure race conditions don't happen. The race condition is prevented by os-brick using manual scans if they are available in the iSCSI client, or a file lock if not. The problem we face now is that we also want to use the lock for NVMe-oF volumes that share a subsystem for multiple namespaces (there is no way to disable automatic scans), but cinder doesn't (and shouldn't) expose the actual storage protocol on the volume resource, so we need to leverage the "shared_targets" parameter. So with a single boolean value we need to encode 3 possible options: - Don't use locks because targets/subystems are not shared - Use locks if iSCSI client doesn't support automatic connections - Always use locks (for example for NVMe-oF) The only option we have is using the "None" value as well. That way we can encode 3 different cases. But we have an additional restriction, "True" is already taken for the iSCSI case, because there will exist volumes in the database that already have that value stored. And making guard_connection always lock when shared_targets is set to True will introduce the bottleneck from bug (#1800515). That leaves us with the "None" value to force the use of locks. So we end up with the following tristate for "shared_targets": - True to use lock if iSCSI initiator doesn't support manual scans - False means that os-brick should never lock. - None means that os-brick should always lock. The alternative to this encoding would be to have an online data migration for volumes to change "True" to "None", and accept that there could be race conditions during the rolling upgrade (because os-brick on computes will interpret "None" as "False"). Since "in theory" Cinder was only returning True or False for the "shared_target", we add a new microversion with number 3.69 that returns null when the value is internally set to None. The patch also updates the database with a migration, though it looks like it's not necessary since the DB already allows null values, but it seems more correct to make sure that's always the case. This patch doesn't close but #1961102 because the os-brick patch is needed for that. Related-Bug: #1961102 Change-Id: I8cda6d9830f39e27ac700b1d8796fe0489fd7c0a
- Loading branch information
Showing
22 changed files
with
403 additions
and
16 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
41 changes: 41 additions & 0 deletions
41
api-ref/source/v3/samples/volumes/v3.69/volume-create-response.json
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,41 @@ | ||
{ | ||
"volume": { | ||
"attachments": [], | ||
"availability_zone": "nova", | ||
"bootable": "false", | ||
"consistencygroup_id": null, | ||
"created_at": "2018-11-28T06:21:12.715987", | ||
"description": null, | ||
"encrypted": false, | ||
"id": "2b955850-f177-45f7-9f49-ecb2c256d161", | ||
"links": [ | ||
{ | ||
"href": "http://127.0.0.1:33951/v3/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/volumes/2b955850-f177-45f7-9f49-ecb2c256d161", | ||
"rel": "self" | ||
}, | ||
{ | ||
"href": "http://127.0.0.1:33951/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/volumes/2b955850-f177-45f7-9f49-ecb2c256d161", | ||
"rel": "bookmark" | ||
} | ||
], | ||
"metadata": {}, | ||
"migration_status": null, | ||
"multiattach": false, | ||
"name": null, | ||
"replication_status": null, | ||
"size": 10, | ||
"snapshot_id": null, | ||
"source_volid": null, | ||
"status": "creating", | ||
"updated_at": null, | ||
"user_id": "c853ca26-e8ea-4797-8a52-ee124a013d0e", | ||
"volume_type": "__DEFAULT__", | ||
"group_id": null, | ||
"provider_id": null, | ||
"service_uuid": null, | ||
"shared_targets": null, | ||
"cluster_name": null, | ||
"volume_type_id": "5fed9d7c-401d-46e2-8e80-f30c70cb7e1d", | ||
"consumes_quota": true | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
api-ref/source/v3/samples/volumes/v3.69/volume-show-response.json
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,45 @@ | ||
{ | ||
"volume": { | ||
"attachments": [], | ||
"availability_zone": "nova", | ||
"bootable": "false", | ||
"consistencygroup_id": null, | ||
"created_at": "2018-11-29T06:50:07.770785", | ||
"description": null, | ||
"encrypted": false, | ||
"id": "f7223234-1afc-4d19-bfa3-d19deb6235ef", | ||
"links": [ | ||
{ | ||
"href": "http://127.0.0.1:45839/v3/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/volumes/f7223234-1afc-4d19-bfa3-d19deb6235ef", | ||
"rel": "self" | ||
}, | ||
{ | ||
"href": "http://127.0.0.1:45839/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/volumes/f7223234-1afc-4d19-bfa3-d19deb6235ef", | ||
"rel": "bookmark" | ||
} | ||
], | ||
"metadata": {}, | ||
"migration_status": null, | ||
"multiattach": false, | ||
"name": null, | ||
"os-vol-host-attr:host": null, | ||
"os-vol-mig-status-attr:migstat": null, | ||
"os-vol-mig-status-attr:name_id": null, | ||
"os-vol-tenant-attr:tenant_id": "89afd400-b646-4bbc-b12b-c0a4d63e5bd3", | ||
"replication_status": null, | ||
"size": 10, | ||
"snapshot_id": null, | ||
"source_volid": null, | ||
"status": "creating", | ||
"updated_at": null, | ||
"user_id": "c853ca26-e8ea-4797-8a52-ee124a013d0e", | ||
"volume_type": "__DEFAULT__", | ||
"provider_id": null, | ||
"group_id": null, | ||
"service_uuid": null, | ||
"shared_targets": null, | ||
"cluster_name": null, | ||
"volume_type_id": "5fed9d7c-401d-46e2-8e80-f30c70cb7e1d", | ||
"consumes_quota": true | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
api-ref/source/v3/samples/volumes/v3.69/volume-update-response.json
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,43 @@ | ||
{ | ||
"volume": { | ||
"attachments": [], | ||
"availability_zone": "nova", | ||
"bootable": "false", | ||
"consistencygroup_id": null, | ||
"created_at": "2018-11-29T06:59:23.679903", | ||
"description": "This is yet, another volume.", | ||
"encrypted": false, | ||
"id": "8b2459d1-0059-4e14-a89f-dfa73a452af6", | ||
"links": [ | ||
{ | ||
"href": "http://127.0.0.1:41467/v3/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/volumes/8b2459d1-0059-4e14-a89f-dfa73a452af6", | ||
"rel": "self" | ||
}, | ||
{ | ||
"href": "http://127.0.0.1:41467/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/volumes/8b2459d1-0059-4e14-a89f-dfa73a452af6", | ||
"rel": "bookmark" | ||
} | ||
], | ||
"metadata": { | ||
"name": "metadata0" | ||
}, | ||
"migration_status": null, | ||
"multiattach": false, | ||
"name": "vol-003", | ||
"replication_status": null, | ||
"size": 10, | ||
"snapshot_id": null, | ||
"source_volid": null, | ||
"status": "creating", | ||
"updated_at": null, | ||
"user_id": "c853ca26-e8ea-4797-8a52-ee124a013d0e", | ||
"volume_type": "__DEFAULT__", | ||
"group_id": null, | ||
"provider_id": null, | ||
"service_uuid": null, | ||
"shared_targets": null, | ||
"cluster_name": null, | ||
"volume_type_id": "5fed9d7c-401d-46e2-8e80-f30c70cb7e1d", | ||
"consumes_quota": true | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
api-ref/source/v3/samples/volumes/v3.69/volumes-list-detailed-response.json
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,47 @@ | ||
{ | ||
"volumes": [ | ||
{ | ||
"attachments": [], | ||
"availability_zone": "nova", | ||
"bootable": "false", | ||
"consistencygroup_id": null, | ||
"created_at": "2018-11-28T06:25:15.288987", | ||
"description": null, | ||
"encrypted": false, | ||
"id": "cb49b381-9012-40cb-b8ee-80c19a4801b5", | ||
"links": [ | ||
{ | ||
"href": "http://127.0.0.1:43543/v3/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/volumes/cb49b381-9012-40cb-b8ee-80c19a4801b5", | ||
"rel": "self" | ||
}, | ||
{ | ||
"href": "http://127.0.0.1:43543/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/volumes/cb49b381-9012-40cb-b8ee-80c19a4801b5", | ||
"rel": "bookmark" | ||
} | ||
], | ||
"metadata": {}, | ||
"migration_status": null, | ||
"multiattach": false, | ||
"name": null, | ||
"os-vol-host-attr:host": null, | ||
"os-vol-mig-status-attr:migstat": null, | ||
"os-vol-mig-status-attr:name_id": null, | ||
"os-vol-tenant-attr:tenant_id": "89afd400-b646-4bbc-b12b-c0a4d63e5bd3", | ||
"replication_status": null, | ||
"size": 10, | ||
"snapshot_id": null, | ||
"source_volid": null, | ||
"status": "creating", | ||
"updated_at": null, | ||
"user_id": "c853ca26-e8ea-4797-8a52-ee124a013d0e", | ||
"volume_type": "__DEFAULT__", | ||
"volume_type_id": "5fed9d7c-401d-46e2-8e80-f30c70cb7e1d", | ||
"provider_id": null, | ||
"group_id": null, | ||
"service_uuid": null, | ||
"shared_targets": null, | ||
"cluster_name": null, | ||
"consumes_quota": true | ||
} | ||
] | ||
} |
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
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
50 changes: 50 additions & 0 deletions
50
cinder/db/migrations/versions/c92a3e68beed_make_shared_targets_nullable.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,50 @@ | ||
# 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. | ||
|
||
"""Make shared_targets nullable | ||
Revision ID: c92a3e68beed | ||
Revises: 921e1a36b076 | ||
Create Date: 2022-03-23 21:30:18.585830 | ||
""" | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = 'c92a3e68beed' | ||
down_revision = '921e1a36b076' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
connection = op.get_bind() | ||
|
||
# Preserve existing type, be it boolean or tinyint treated as boolean | ||
table = sa.Table('volumes', sa.MetaData(), autoload_with=connection) | ||
existing_type = table.c.shared_targets.type | ||
|
||
# SQLite doesn't support altering tables, so we use a workaround | ||
if connection.engine.name == 'sqlite': | ||
with op.batch_alter_table('volumes') as batch_op: | ||
batch_op.alter_column('shared_targets', | ||
existing_type=existing_type, | ||
type_=sa.Boolean(), | ||
nullable=True) | ||
|
||
else: | ||
op.alter_column('volumes', 'shared_targets', | ||
existing_type=existing_type, | ||
type_=sa.Boolean(), | ||
nullable=True) |
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.