Isolate certain images on certain hosts.

This implements a [hosts] <=> [images] mapping in the simple scheduler
that partitions your host resources into the part that services a
particular image set, and the general cloud.  This is useful, for
example, if you want to specify a set of hosts to run utility VMs
(cloudpipe, bastion, etc) that you don't want consuming resources from
your generally available pool.

When specifying a host with --isolated_hosts flags (comma-separated
list) those hosts will only run the images specified in
--isolated_images, and will not run any other images.  The isolated
images will not run on any other hosts.

You can specify --skip_isolated_core_check to allow overcommitting of
the isolated hosts.  This allows utility vms that are not cpu bound to
avoid the resource cheks the scheduler usually performs (based off of
--max_cores).

Change-Id: Ib2db5a605cb7560a169af9ff2a6dadb649da9c1d
This commit is contained in:
Todd Willey
2012-01-08 12:51:35 -05:00
parent 85b070cb89
commit 0e7e3b2c18

View File

@@ -36,6 +36,10 @@ flags.DEFINE_integer("max_networks", 1000,
"maximum number of networks to allow per host") "maximum number of networks to allow per host")
flags.DEFINE_string('default_schedule_zone', None, flags.DEFINE_string('default_schedule_zone', None,
'zone to use when user doesnt specify one') 'zone to use when user doesnt specify one')
flags.DEFINE_list('isolated_images', [], 'Images to run on isolated host')
flags.DEFINE_list('isolated_hosts', [], 'Host reserved for specific images')
flags.DEFINE_boolean('skip_isolated_core_check', True,
'Allow overcommitting vcpus on isolated hosts')
class SimpleScheduler(chance.ChanceScheduler): class SimpleScheduler(chance.ChanceScheduler):
@@ -58,12 +62,21 @@ class SimpleScheduler(chance.ChanceScheduler):
return host return host
results = db.service_get_all_compute_sorted(elevated) results = db.service_get_all_compute_sorted(elevated)
in_isolation = instance_opts['image_ref'] in FLAGS.isolated_images
check_cores = not in_isolation or not FLAGS.skip_isolated_core_check
if zone: if zone:
results = [(service, cores) for (service, cores) in results results = [(service, cores) for (service, cores) in results
if service['availability_zone'] == zone] if service['availability_zone'] == zone]
for result in results: for result in results:
(service, instance_cores) = result (service, instance_cores) = result
if instance_cores + instance_opts['vcpus'] > FLAGS.max_cores: if in_isolation and service['host'] not in FLAGS.isolated_hosts:
# isloated images run on isolated hosts
continue
if service['host'] in FLAGS.isolated_hosts and not in_isolation:
# images that aren't isolated only run on general hosts
continue
if check_cores and \
instance_cores + instance_opts['vcpus'] > FLAGS.max_cores:
msg = _("Not enough allocatable CPU cores remaining") msg = _("Not enough allocatable CPU cores remaining")
raise exception.NoValidHost(reason=msg) raise exception.NoValidHost(reason=msg)
if self.service_is_up(service): if self.service_is_up(service):