scheduler hints can be injected when extension is off

Bug #1025737 reported by Brian Waldon
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
High
Sean Dague

Bug Description

The scheduler hints extension converts a server create request like {'server': {'name': 'foo'}, 'os:scheduler_hints': {'near': 'bar'}} to {'server': {'name': 'foo', 'scheduler_hints': 'bar'}}. If the extension is off, that conversion does not take place. However, a user can explicitly set the 'scheduler_hints' value inside the 'server' dictionary when the extension is off and the data will be consume by the core api controller.

I would expect when the extension is off that any scheduler hints would be ignored.

Changed in nova:
assignee: nobody → jiang, yunhong (yunhong-jiang)
Revision history for this message
jiang, yunhong (yunhong-jiang) wrote :

As the extension code will be executed before servers.py, I didn't think out a good method to distinguish whether the "scheduler_hints" in request body is set by the schedule hints extensions or by user directly.

I considered that it's possible that the schedule hints extension set the req's environment, like followed draft show. With this changes, even user set the "scheduler_hints" in the server dictionary, it will not be utilized. The servers.py always get scheduler hints from the wsgi environment.

However, I'm not quite sure if this is the right and clean solution, because I'm not sure if the wsgi environment fits for this purpose. Although my quick test showed it works.

Brian, how do you think of this? If it's acceptable, I will do more testing on it.

Thanks
--jyh

diff --git a/nova/api/openstack/compute/contrib/scheduler_hints.py b/nova/api/op
index 86b7564..d97d0bd 100644
--- a/nova/api/openstack/compute/contrib/scheduler_hints.py
+++ b/nova/api/openstack/compute/contrib/scheduler_hints.py
@@ -46,7 +46,7 @@ class SchedulerHintsController(wsgi.Controller):
     @wsgi.extends
     def create(self, req, body):
         hints = self._extract_scheduler_hints(body)
- body['server']['scheduler_hints'] = hints
+ req.environ['nova.scheduler_hints'] = hints
         yield

diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/
index 0b37b5c..42a5036 100644
--- a/nova/api/openstack/compute/servers.py
+++ b/nova/api/openstack/compute/servers.py
@@ -678,7 +678,7 @@ class Controller(wsgi.Controller):
             min_count = max_count

         auto_disk_config = server_dict.get('auto_disk_config')
- scheduler_hints = server_dict.get('scheduler_hints', {})
+ scheduler_hints = req.environ['nova.scheduler_hints']

         try:
             _get_inst_type = instance_types.get_instance_type_by_flavor_id
~

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

Fix proposed to branch: master
Review: https://review.openstack.org/10770

Changed in nova:
status: Triaged → In Progress
Revision history for this message
Vish Ishaya (vishvananda) wrote :

Fixed by:

https://review.openstack.org/#/c/11051/

bug was not linked

Changed in nova:
status: In Progress → Fix Committed
assignee: jiang, yunhong (yunhong-jiang) → Sean Dague (sdague-b)
Thierry Carrez (ttx)
Changed in nova:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: folsom-3 → 2012.2
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.