Stock zones follows a fill-first methodology—the current zone is filled with instances before other zones are considered. This adds a flag to nova to select a spread-first methodology. The implementation is simply adding a random.shuffle() prior to sorting the list of potential compute hosts by weights.

This commit is contained in:
Kevin L. Mitchell
2011-09-09 22:22:10 +00:00
committed by Tarmac
2 changed files with 8 additions and 1 deletions

View File

@@ -20,8 +20,8 @@ customize the behavior: filter_hosts() and weigh_hosts(). The default
behavior is to simply select all hosts and weight them the same. behavior is to simply select all hosts and weight them the same.
""" """
import operator
import json import json
import operator
import M2Crypto import M2Crypto

View File

@@ -27,6 +27,8 @@ from nova.scheduler import abstract_scheduler
from nova.scheduler import host_filter from nova.scheduler import host_filter
FLAGS = flags.FLAGS FLAGS = flags.FLAGS
flags.DEFINE_boolean('spread_first', False,
'Use a spread-first zone scheduler strategy')
LOG = logging.getLogger('nova.scheduler.base_scheduler') LOG = logging.getLogger('nova.scheduler.base_scheduler')
@@ -68,4 +70,9 @@ class BaseScheduler(abstract_scheduler.AbstractScheduler):
if num_instances > 0: if num_instances > 0:
instances.extend(hosts[:num_instances]) instances.extend(hosts[:num_instances])
# Adjust the weights for a spread-first strategy
if FLAGS.spread_first:
for i, host in enumerate(hosts):
host['weight'] = i + 1
return instances return instances