Use elevated context to query DB in VolumeNumberWeigher
Currently tenant would fail to create volume, if cinder uses VolumeNumberWeigher. This will elevate tenant to admin privilege, then VolumeNumberWeigher has the privilege to get volume count of each hosts. Change-Id: I1aa0e8ad74d37389ad1feecef113ab8e260dfd0f Closes-Bug: #1594294
This commit is contained in:
@@ -50,6 +50,7 @@ class VolumeNumberWeigher(weights.BaseHostWeigher):
|
||||
We want spreading to be the default.
|
||||
"""
|
||||
context = weight_properties['context']
|
||||
context = context.elevated()
|
||||
volume_number = db.volume_data_get_for_host(context=context,
|
||||
host=host_state.host,
|
||||
count_only=True)
|
||||
|
||||
Reference in New Issue
Block a user