diff options
| author | Kevin L. Mitchell <kevin.mitchell@rackspace.com> | 2011-09-09 14:35:38 -0500 |
|---|---|---|
| committer | Kevin L. Mitchell <kevin.mitchell@rackspace.com> | 2011-09-09 14:35:38 -0500 |
| commit | d05d4e77df0bdfd2b802186762391d7f91361701 (patch) | |
| tree | d87a77bea7f36b668d28e7e6be7c99d6232da566 | |
| parent | baf9435d2a1be8bbfd27278b19f6f35bb3e316ea (diff) | |
| download | nova-d05d4e77df0bdfd2b802186762391d7f91361701.tar.gz nova-d05d4e77df0bdfd2b802186762391d7f91361701.tar.xz nova-d05d4e77df0bdfd2b802186762391d7f91361701.zip | |
Add comment to document why random.shuffle() works
| -rw-r--r-- | nova/scheduler/abstract_scheduler.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/nova/scheduler/abstract_scheduler.py b/nova/scheduler/abstract_scheduler.py index b4c2bf4f1..e4f615b94 100644 --- a/nova/scheduler/abstract_scheduler.py +++ b/nova/scheduler/abstract_scheduler.py @@ -296,6 +296,13 @@ class AbstractScheduler(driver.Scheduler): "child_blob": weighting["blob"]} weighted_hosts.append(host_dict) if FLAGS.spread_first: + # NOTE(Vek): If all the weights are unique, then the sort + # below undoes this shuffle; however, if + # several responses from several zones have the + # same weight, then this shuffle serves to + # break up the monolithic blocks and cause the + # instances to be uniformly spread across the + # zones. random.shuffle(weighted_hosts) weighted_hosts.sort(key=operator.itemgetter('weight')) return weighted_hosts |
