Skip to content

Commit 00454f6

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "scheduler: Merge 'FilterScheduler' into base class"
2 parents eedbff3 + e0534cc commit 00454f6

File tree

11 files changed

+589
-681
lines changed

11 files changed

+589
-681
lines changed

doc/source/contributor/testing/eventlet-profiling.rst

Lines changed: 17 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ better to begin the process with a candidate task or method *within* the
3333
service that can be associated with an identifier. For example,
3434
``select_destinations`` in the ``FilterScheduler`` can be associated with the
3535
list of ``instance_uuids`` passed to it and it runs only once for that set of
36-
instance uuids.
36+
instance UUIDs.
3737

3838
The process for profiling is:
3939

@@ -100,80 +100,39 @@ profiling and benchmarking scenarios so not all changes are relevant here):
100100
[notifications]
101101
notification_format = unversioned
102102
103-
Change the code in ``nova/scheduler/filter_scheduler.py`` as follows:
103+
Change the code in ``nova/scheduler/driver.py`` as follows to start the
104+
profiler at the start of ``select_destinations`` call and to dump the
105+
statistics at the end. For example:
104106

105107
.. code-block:: diff
106108
107-
108-
diff --git a/nova/scheduler/filter_scheduler.py b/nova/scheduler/filter_scheduler.py
109-
index 672f23077e..cb0f87fe48 100644
110-
--- a/nova/scheduler/filter_scheduler.py
111-
+++ b/nova/scheduler/filter_scheduler.py
112-
@@ -49,92 +49,99 @@ class FilterScheduler(driver.Scheduler):
113-
def select_destinations(self, context, spec_obj, instance_uuids,
114-
alloc_reqs_by_rp_uuid, provider_summaries,
115-
allocation_request_version=None, return_alternates=False):
116-
"""Returns a list of lists of Selection objects, which represent the
117-
hosts and (optionally) alternates for each instance.
118-
119-
:param context: The RequestContext object
120-
:param spec_obj: The RequestSpec object
121-
:param instance_uuids: List of UUIDs, one for each value of the spec
122-
object's num_instances attribute
123-
:param alloc_reqs_by_rp_uuid: Optional dict, keyed by resource provider
124-
UUID, of the allocation_requests that may
125-
be used to claim resources against
126-
matched hosts. If None, indicates either
127-
the placement API wasn't reachable or
128-
that there were no allocation_requests
129-
returned by the placement API. If the
130-
latter, the provider_summaries will be an
131-
empty dict, not None.
132-
:param provider_summaries: Optional dict, keyed by resource provider
133-
UUID, of information that will be used by
134-
the filters/weighers in selecting matching
135-
hosts for a request. If None, indicates that
136-
the scheduler driver should grab all compute
137-
node information locally and that the
138-
Placement API is not used. If an empty dict,
139-
indicates the Placement API returned no
140-
potential matches for the requested
141-
resources.
142-
:param allocation_request_version: The microversion used to request the
143-
allocations.
144-
:param return_alternates: When True, zero or more alternate hosts are
145-
returned with each selected host. The number
146-
of alternates is determined by the
147-
configuration option
148-
`CONF.scheduler.max_attempts`.
109+
diff --git nova/scheduler/driver.py nova/scheduler/driver.py
110+
index 555236e8a1..efa84b5a47 100644
111+
--- nova/scheduler/driver.py
112+
+++ nova/scheduler/driver.py
113+
@@ -95,6 +95,10 @@ class SchedulerDriver:
114+
determined by the configuration option
115+
`CONF.scheduler.max_attempts`.
149116
"""
150117
+ from eventlet.green import profile
151118
+ pr = profile.Profile()
152119
+ pr.start()
153120
+
154121
self.notifier.info(
155122
context, 'scheduler.select_destinations.start',
156-
dict(request_spec=spec_obj.to_legacy_request_spec_dict()))
157-
compute_utils.notify_about_scheduler_action(
158-
context=context, request_spec=spec_obj,
159-
action=fields_obj.NotificationAction.SELECT_DESTINATIONS,
160-
phase=fields_obj.NotificationPhase.START)
161-
162-
host_selections = self._schedule(context, spec_obj, instance_uuids,
163-
alloc_reqs_by_rp_uuid, provider_summaries,
164-
allocation_request_version, return_alternates)
165-
self.notifier.info(
166-
context, 'scheduler.select_destinations.end',
167-
dict(request_spec=spec_obj.to_legacy_request_spec_dict()))
168-
compute_utils.notify_about_scheduler_action(
123+
{'request_spec': spec_obj.to_legacy_request_spec_dict()})
124+
@@ -114,6 +118,10 @@ class SchedulerDriver:
169125
context=context, request_spec=spec_obj,
170126
action=fields_obj.NotificationAction.SELECT_DESTINATIONS,
171127
phase=fields_obj.NotificationPhase.END)
128+
+
172129
+ pr.stop()
173130
+ pr.dump_stats('/tmp/select_destinations/%s.prof' % ':'.join(instance_uuids))
174131
+
175132
return host_selections
176133
134+
def _schedule(
135+
177136
Make a ``/tmp/select_destinations`` directory that is writable by the user
178137
nova-scheduler will run as. This is where the profile output will go.
179138

@@ -189,7 +148,7 @@ Create a server (which will call ``select_destinations``)::
189148
openstack server create --image cirros-0.4.0-x86_64-disk --flavor c1 x1
190149

191150
In ``/tmp/select_destinations`` there should be a file with a name using the
192-
uuid of the created server with a ``.prof`` extension.
151+
UUID of the created server with a ``.prof`` extension.
193152

194153
Change to that directory and view the profile using the pstats
195154
`interactive mode`_::

nova/conductor/tasks/migrate.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,12 @@ def replace_allocation_with_migration(context, instance, migration):
6060
context, instance.uuid)['allocations']
6161
root_alloc = orig_alloc.get(source_cn.uuid, {}).get('resources', {})
6262
if not root_alloc:
63-
LOG.debug('Unable to find existing allocations for instance on '
64-
'source compute node: %s. This is normal if you are not '
65-
'using the FilterScheduler.', source_cn.uuid,
66-
instance=instance)
63+
# TODO(stephenfin): This was a valid code path when there was support
64+
# for multiple schedulers, but it should probably be an error now
65+
LOG.debug(
66+
'Unable to find existing allocations for instance on '
67+
'source compute node: %s',
68+
source_cn.uuid, instance=instance)
6769
return None, None
6870

6971
# FIXME(gibi): This method is flawed in that it does not handle allocations

0 commit comments

Comments
 (0)