@@ -227,106 +227,6 @@ def _is_selected_host_in_source_cell(self, selection):
227227 instance = self .instance )
228228 return same_cell
229229
230- def _support_resource_request (self , selection ):
231- """Returns true if the host is new enough to support resource request
232- during migration and that the RPC API version is not pinned during
233- rolling upgrade.
234- """
235- svc = objects .Service .get_by_host_and_binary (
236- self .context , selection .service_host , 'nova-compute' )
237- return (svc .version >= 39 and
238- self .compute_rpcapi .supports_resize_with_qos_port (
239- self .context ))
240-
241- # TODO(gibi): Remove this compat code when nova doesn't need to support
242- # Train computes any more.
243- def _get_host_supporting_request (self , selection_list ):
244- """Return the first compute selection from the selection_list where
245- the service is new enough to support resource request during migration
246- and the resources claimed successfully.
247-
248- :param selection_list: a list of Selection objects returned by the
249- scheduler
250- :return: A two tuple. The first item is a Selection object
251- representing the host that supports the request. The second item
252- is a list of Selection objects representing the remaining alternate
253- hosts.
254- :raises MaxRetriesExceeded: if none of the hosts in the selection_list
255- is new enough to support the request or we cannot claim resource
256- on any of the hosts that are new enough.
257- """
258-
259- if not self .request_spec .requested_resources :
260- return selection_list [0 ], selection_list [1 :]
261-
262- # Scheduler allocated resources on the first host. So check if the
263- # first host is new enough
264- if self ._support_resource_request (selection_list [0 ]):
265- return selection_list [0 ], selection_list [1 :]
266-
267- # First host is old, so we need to use an alternate. Therefore we have
268- # to remove the allocation from the first host.
269- self .reportclient .delete_allocation_for_instance (
270- self .context , self .instance .uuid )
271- LOG .debug (
272- 'Scheduler returned host %(host)s as a possible migration target '
273- 'but that host is not new enough to support the migration with '
274- 'resource request %(request)s or the compute RPC is pinned to '
275- 'less than 5.2. Trying alternate hosts.' ,
276- {'host' : selection_list [0 ].service_host ,
277- 'request' : self .request_spec .requested_resources },
278- instance = self .instance )
279-
280- alternates = selection_list [1 :]
281-
282- for i , selection in enumerate (alternates ):
283- if self ._support_resource_request (selection ):
284- # this host is new enough so we need to try to claim resources
285- # on it
286- if selection .allocation_request :
287- alloc_req = jsonutils .loads (
288- selection .allocation_request )
289- resource_claimed = scheduler_utils .claim_resources (
290- self .context , self .reportclient , self .request_spec ,
291- self .instance .uuid , alloc_req ,
292- selection .allocation_request_version )
293-
294- if not resource_claimed :
295- LOG .debug (
296- 'Scheduler returned alternate host %(host)s as a '
297- 'possible migration target but resource claim '
298- 'failed on that host. Trying another alternate.' ,
299- {'host' : selection .service_host },
300- instance = self .instance )
301- else :
302- return selection , alternates [i + 1 :]
303-
304- else :
305- # Some deployments use different schedulers that do not
306- # use Placement, so they will not have an
307- # allocation_request to claim with. For those cases,
308- # there is no concept of claiming, so just assume that
309- # the resources are available.
310- return selection , alternates [i + 1 :]
311-
312- else :
313- LOG .debug (
314- 'Scheduler returned alternate host %(host)s as a possible '
315- 'migration target but that host is not new enough to '
316- 'support the migration with resource request %(request)s '
317- 'or the compute RPC is pinned to less than 5.2. '
318- 'Trying another alternate.' ,
319- {'host' : selection .service_host ,
320- 'request' : self .request_spec .requested_resources },
321- instance = self .instance )
322-
323- # if we reach this point then none of the hosts was new enough for the
324- # request or we failed to claim resources on every alternate
325- reason = ("Exhausted all hosts available during compute service level "
326- "check for instance %(instance_uuid)s." %
327- {"instance_uuid" : self .instance .uuid })
328- raise exception .MaxRetriesExceeded (reason = reason )
329-
330230 def _execute (self ):
331231 # NOTE(sbauza): Force_hosts/nodes needs to be reset if we want to make
332232 # sure that the next destination is not forced to be the original host.
@@ -436,8 +336,8 @@ def _schedule(self):
436336 # just need the first returned element.
437337 selection_list = selection_lists [0 ]
438338
439- selection , self . host_list = self . _get_host_supporting_request (
440- selection_list )
339+ # Scheduler allocated resources on the first host so try that first
340+ selection , self . host_list = selection_list [ 0 ], selection_list [ 1 :]
441341
442342 scheduler_utils .fill_provider_mapping (self .request_spec , selection )
443343 return selection
@@ -452,17 +352,6 @@ def _reschedule(self):
452352 selection = None
453353 while self .host_list and not host_available :
454354 selection = self .host_list .pop (0 )
455- if (self .request_spec .requested_resources and not
456- self ._support_resource_request (selection )):
457- LOG .debug (
458- 'Scheduler returned alternate host %(host)s as a possible '
459- 'migration target for re-schedule but that host is not '
460- 'new enough to support the migration with resource '
461- 'request %(request)s. Trying another alternate.' ,
462- {'host' : selection .service_host ,
463- 'request' : self .request_spec .requested_resources },
464- instance = self .instance )
465- continue
466355 if selection .allocation_request :
467356 alloc_req = jsonutils .loads (selection .allocation_request )
468357 else :
0 commit comments