]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fix volume throttling to Python 3
authorVictor Stinner <vstinner@redhat.com>
Thu, 1 Oct 2015 16:04:30 +0000 (18:04 +0200)
committerVictor Stinner <vstinner@redhat.com>
Fri, 2 Oct 2015 07:01:03 +0000 (07:01 +0000)
BlkioCgroup._set_limits(): sort devices before iterating on them to
have a reliable behaviour.

The devs variable is a dictionary. On Python 3, the hash function is
now randomized, so iterating on a dictionary gives items in a random
order. Use sorted() to iterate on the list of sorted devices instead.

tox.ini: add cinder.tests.unit.test_volume_throttling to Python 3.

Blueprint cinder-python3
Partial-Bug: #1348818
Change-Id: Icf7141f772397c7ac08f0f1e21ad74cb86a06351

cinder/volume/throttling.py
tox.ini

index 21c19956e16d2a6fc366b32a6abb31d566b5b849..b8ce5705ab0b320000d67bd14fed5d73e27e3cfa 100644 (file)
@@ -90,7 +90,7 @@ class BlkioCgroup(Throttle):
 
     def _set_limits(self, rw, devs):
         total = sum(devs.values())
-        for dev in devs:
+        for dev in sorted(devs):
             self._limit_bps(rw, dev, self.bps_limit * devs[dev] / total)
 
     @utils.synchronized('BlkioCgroup')
diff --git a/tox.ini b/tox.ini
index 720d144927568e4347fa36cb6f318573e5caf6aa..d86012f2008a58612f8d1e0d4c680411ec792319 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -103,6 +103,7 @@ commands =
     cinder.tests.unit.test_volume_configuration \
     cinder.tests.unit.test_volume_glance_metadata \
     cinder.tests.unit.test_volume_rpcapi \
+    cinder.tests.unit.test_volume_throttling \
     cinder.tests.unit.test_volume_transfer \
     cinder.tests.unit.test_volume_types \
     cinder.tests.unit.test_volume_types_extra_specs \