Andrew Bogott has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/203969

Change subject: Add a custom pool-based filter for nova scheduler.
......................................................................

Add a custom pool-based filter for nova scheduler.

I want to be able to remove compute nodes from the scheduler without
turning off compute on those nodes.  This should be supported
using host aggregates in nova, but that seems to be broken
in Icehouse and/or in our install.

Change-Id: I0c98a8ae8543a2c514097d107b1bb0b14136bdc9
---
A modules/openstack/files/icehouse/nova/scheduler_pool_filter.py
M modules/openstack/manifests/nova/scheduler.pp
M modules/openstack/templates/icehouse/nova/nova.conf.erb
3 files changed, 55 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/69/203969/1

diff --git a/modules/openstack/files/icehouse/nova/scheduler_pool_filter.py 
b/modules/openstack/files/icehouse/nova/scheduler_pool_filter.py
new file mode 100644
index 0000000..96a45ee
--- /dev/null
+++ b/modules/openstack/files/icehouse/nova/scheduler_pool_filter.py
@@ -0,0 +1,44 @@
+# Copyright (c) 2015 Andrew Bogott for Wikimedia Foundation
+# All Rights Reserved.
+#
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
+#    not use this file except in compliance with the License. You may obtain
+#    a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+#    License for the specific language governing permissions and limitations
+#    under the License.
+
+from oslo.config import cfg
+from nova.openstack.common import log as logging
+
+from nova import db
+from nova.scheduler import filters
+
+LOG = logging.getLogger(__name__)
+
+pool_opt = cfg.ListOpt('wmf_scheduler_hosts_pool',
+                       help='Lists of hosts permitted to schedule new 
instances',
+                       default=None)
+CONF = cfg.CONF
+CONF.register_opt(pool_opt)
+
+
+class SchedulerPoolFilter(filters.BaseHostFilter):
+    """Filters Hosts according to a simple config setting"""
+
+    # This won't change within a request
+    run_filter_once_per_request = True
+
+    def host_passes(self, host_state, filter_properties):
+        pool = CONF.wmf_scheduler_hosts_pool
+        if pool is None:
+            LOG.debug("Host pool is unspecified, allowing all available 
hosts.")
+            return True
+        else:
+            LOG.debug("Filtering according to the host pool: %s" % pool)
+            return host_state.host in pool
diff --git a/modules/openstack/manifests/nova/scheduler.pp 
b/modules/openstack/manifests/nova/scheduler.pp
index 43deb55..19dfe23 100644
--- a/modules/openstack/manifests/nova/scheduler.pp
+++ b/modules/openstack/manifests/nova/scheduler.pp
@@ -16,5 +16,14 @@
         description  => 'nova-scheduler process',
         nrpe_command => "/usr/lib/nagios/plugins/check_procs -c 1: 
--ereg-argument-array '^/usr/bin/python /usr/bin/nova-scheduler'",
     }
+
+    file { 
'/usr/lib/python2.7/dist-packages/nova/scheduler/filters/scheduler_pool_filter.py':
+        source  => 
"puppet:///modules/openstack/${openstack_version}/nova/scheduler_pool_filter.py",
+        notify  => Service['nova-scheduler'],
+        owner   => 'root',
+        group   => 'root',
+        mode    => '0444',
+        require => Package['nova-scheduler'],
+    }
 }
 
diff --git a/modules/openstack/templates/icehouse/nova/nova.conf.erb 
b/modules/openstack/templates/icehouse/nova/nova.conf.erb
index 1697d7c..842fd67 100644
--- a/modules/openstack/templates/icehouse/nova/nova.conf.erb
+++ b/modules/openstack/templates/icehouse/nova/nova.conf.erb
@@ -8,7 +8,8 @@
 instance_name_template=i-%08x
 daemonize=1
 scheduler_driver=nova.scheduler.filter_scheduler.FilterScheduler
-scheduler_default_filters=RetryFilter,AvailabilityZoneFilter,RamFilter,ComputeFilter,ComputeCapabilitiesFilter,ImagePropertiesFilter,ServerGroupAntiAffinityFilter,ServerGroupAffinityFilter,AggregateInstanceExtraSpecsFilter,AvailabilityZoneFilter
+wmf_scheduler_hosts_pool=virt1001,virt1002,virt1003,virt1004,virt1007,virt1008,virt1009,virt1010,virt1011,virt1012
+scheduler_default_filters=RetryFilter,AvailabilityZoneFilter,RamFilter,ComputeFilter,ComputeCapabilitiesFilter,ImagePropertiesFilter,ServerGroupAntiAffinityFilter,ServerGroupAffinityFilter,AggregateInstanceExtraSpecsFilter,AvailabilityZoneFilter,SchedulerPoolFilter
 
 # Don't allow duplicate instance names
 osapi_compute_unique_server_name_scope='global'

-- 
To view, visit https://gerrit.wikimedia.org/r/203969
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0c98a8ae8543a2c514097d107b1bb0b14136bdc9
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Andrew Bogott <abog...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to