Skip to content

Commit 5b393cf

Browse files
authored
Merge pull request #88 from stackhpc/glance_rbd_slow
Fix performance glitch while sorting image locations
2 parents 704eb37 + 34c8ec1 commit 5b393cf

File tree

5 files changed

+14
-16
lines changed

5 files changed

+14
-16
lines changed

bindep.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ postgresql-server [platform:rpm]
2424
postgresql-server-devel [platform:suse] # Provides pg_config
2525
libpython3-dev [platform:dpkg]
2626
python3-devel [platform:rpm]
27-
qemu [platform:dpkg devstack build-image-dib]
28-
qemu-utils [platform:dpkg devstack build-image-dib]
29-
qemu-img [platform:redhat]
30-
qemu-tools [platform:suse] # Provides qemu-img
27+
qemu [platform:dpkg devstack build-image-dib test]
28+
qemu-utils [platform:dpkg devstack build-image-dib test]
29+
qemu-img [platform:redhat test]
30+
qemu-tools [platform:suse test] # Provides qemu-img
3131
libpq-dev [platform:dpkg]
3232
libpcre3-dev [platform:dpkg]
3333
pcre-devel [platform:redhat]

glance/common/utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -724,13 +724,12 @@ def get_store_weight(location):
724724
if not store_id:
725725
return 0
726726
try:
727-
store = glance_store.get_store_from_store_identifier(store_id)
727+
return glance_store.get_store_weight(store_id)
728728
except glance_store.exceptions.UnknownScheme:
729729
msg = (_LW("Unable to find store '%s', returning "
730730
"default weight '0'") % store_id)
731731
LOG.warning(msg)
732732
return 0
733-
return store.weight if store is not None else 0
734733

735734
sorted_locations = sorted(locations, key=get_store_weight, reverse=True)
736735
LOG.debug(('Sorted locations: %s'), sorted_locations)

glance/tests/unit/common/test_utils.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def test_sort_image_locations_multistore_disabled(self):
189189
'url': 'rbd://cccccccc/images/id',
190190
'metadata': {'store': 'rbd3'}
191191
}]
192-
mp = "glance.common.utils.glance_store.get_store_from_store_identifier"
192+
mp = "glance.common.utils.glance_store.get_store_weight"
193193
with mock.patch(mp) as mock_get_store:
194194
utils.sort_image_locations(locations)
195195

@@ -215,10 +215,9 @@ def test_sort_image_locations(self):
215215
'url': 'rbd://cccccccc/images/id',
216216
'metadata': {'store': 'rbd3'}
217217
}]
218-
mp = "glance.common.utils.glance_store.get_store_from_store_identifier"
218+
mp = "glance.common.utils.glance_store.get_store_weight"
219219
with mock.patch(mp) as mock_get_store:
220-
mock_store = mock_get_store.return_value
221-
mock_store.weight = 100
220+
mock_get_store.return_value = 100
222221
utils.sort_image_locations(locations)
223222

224223
# Since 3 stores are configured, internal method will be called 3 times
@@ -243,7 +242,7 @@ def test_sort_image_locations_without_metadata(self):
243242
'url': 'rbd://cccccccc/images/id',
244243
'metadata': {}
245244
}]
246-
mp = "glance.common.utils.glance_store.get_store_from_store_identifier"
245+
mp = "glance.common.utils.glance_store.get_store_weight"
247246
with mock.patch(mp) as mock_get_store:
248247
utils.sort_image_locations(locations)
249248

@@ -270,10 +269,9 @@ def test_sort_image_locations_with_partial_metadata(self):
270269
'url': 'rbd://cccccccc/images/id',
271270
'metadata': {}
272271
}]
273-
mp = "glance.common.utils.glance_store.get_store_from_store_identifier"
272+
mp = "glance.common.utils.glance_store.get_store_weight"
274273
with mock.patch(mp) as mock_get_store:
275-
mock_store = mock_get_store.return_value
276-
mock_store.weight = 100
274+
mock_get_store.return_value = 100
277275
utils.sort_image_locations(locations)
278276

279277
# Since 3 stores are configured, but only one location has
@@ -300,7 +298,7 @@ def test_sort_image_locations_unknownscheme(self):
300298
'url': 'rbd://cccccccc/images/id',
301299
'metadata': {'store': 'rbd3'}
302300
}]
303-
mp = "glance.common.utils.glance_store.get_store_from_store_identifier"
301+
mp = "glance.common.utils.glance_store.get_store_weight"
304302
with mock.patch(mp) as mock_get_store:
305303
mock_get_store.side_effect = store.UnknownScheme()
306304
sorted_locations = utils.sort_image_locations(locations)

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ retrying!=1.3.0,>=1.2.3 # Apache-2.0
4242
osprofiler>=1.4.0 # Apache-2.0
4343

4444
# Glance Store
45-
glance-store>=2.3.0 # Apache-2.0
45+
glance-store @ git+https://github.com/stackhpc/glance_store@stackhpc/4.7.0.3 # Apache-2.0
4646

4747

4848
debtcollector>=1.19.0 # Apache-2.0

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ setenv =
1717
OS_TEST_DBAPI_ADMIN_CONNECTION=sqlite:////tmp/placeholder-never-created-nor-used.db
1818
# TODO(stephenfin): Remove once we bump our upper-constraint to SQLAlchemy 2.0
1919
SQLALCHEMY_WARN_20=1
20+
TOX_CONSTRAINTS_FILE=https://raw.githubusercontent.com/stackhpc/requirements/refs/heads/stackhpc/2024.1/upper-constraints.txt
2021
usedevelop = True
2122
install_command = python -m pip install -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/2024.1} {opts} {packages}
2223
deps = -r{toxinidir}/test-requirements.txt

0 commit comments

Comments
 (0)