@@ -530,7 +530,7 @@ def update_compute_provider_status(self, context, rp_uuid, enabled):
530
530
class ComputeManager(manager.Manager):
531
531
"""Manages the running instances from creation to destruction."""
532
532
533
- target = messaging.Target(version='5.11 ')
533
+ target = messaging.Target(version='5.12 ')
534
534
535
535
def __init__(self, compute_driver=None, *args, **kwargs):
536
536
"""Load configuration options and connect to the hypervisor."""
@@ -3256,25 +3256,44 @@ def _set_migration_status(migration, status):
3256
3256
migration.status = status
3257
3257
migration.save()
3258
3258
3259
- def _rebuild_default_impl(self, context, instance, image_meta,
3260
- injected_files, admin_password, allocations ,
3261
- bdms, detach_block_devices, attach_block_devices ,
3262
- network_info=None,
3263
- evacuate=False, block_device_info=None ,
3264
- preserve_ephemeral=False ):
3259
+ def _rebuild_default_impl(
3260
+ self, context, instance, image_meta, injected_files ,
3261
+ admin_password, allocations, bdms, detach_block_devices,
3262
+ attach_block_devices, network_info=None, evacuate=False ,
3263
+ block_device_info=None, preserve_ephemeral=False ,
3264
+ accel_uuids=None ):
3265
3265
if preserve_ephemeral:
3266
3266
# The default code path does not support preserving ephemeral
3267
3267
# partitions.
3268
3268
raise exception.PreserveEphemeralNotSupported()
3269
3269
3270
+ accel_info = []
3270
3271
if evacuate:
3272
+ if instance.flavor.extra_specs.get('accel:device_profile'):
3273
+ try:
3274
+ accel_info = self._get_bound_arq_resources(
3275
+ context, instance, accel_uuids or [])
3276
+ except (Exception, eventlet.timeout.Timeout) as exc:
3277
+ LOG.exception(exc)
3278
+ self._build_resources_cleanup(instance, network_info)
3279
+ msg = _('Failure getting accelerator resources.')
3280
+ raise exception.BuildAbortException(
3281
+ instance_uuid=instance.uuid, reason=msg)
3271
3282
detach_block_devices(context, bdms)
3272
3283
else:
3273
3284
self._power_off_instance(instance, clean_shutdown=True)
3274
3285
detach_block_devices(context, bdms)
3275
3286
self.driver.destroy(context, instance,
3276
3287
network_info=network_info,
3277
3288
block_device_info=block_device_info)
3289
+ try:
3290
+ accel_info = self._get_accel_info(context, instance)
3291
+ except Exception as exc:
3292
+ LOG.exception(exc)
3293
+ self._build_resources_cleanup(instance, network_info)
3294
+ msg = _('Failure getting accelerator resources.')
3295
+ raise exception.BuildAbortException(
3296
+ instance_uuid=instance.uuid, reason=msg)
3278
3297
3279
3298
instance.task_state = task_states.REBUILD_BLOCK_DEVICE_MAPPING
3280
3299
instance.save(expected_task_state=[task_states.REBUILDING])
@@ -3289,7 +3308,8 @@ def _rebuild_default_impl(self, context, instance, image_meta,
3289
3308
self.driver.spawn(context, instance, image_meta, injected_files,
3290
3309
admin_password, allocations,
3291
3310
network_info=network_info,
3292
- block_device_info=new_block_device_info)
3311
+ block_device_info=new_block_device_info,
3312
+ accel_info=accel_info)
3293
3313
3294
3314
def _notify_instance_rebuild_error(self, context, instance, error, bdms):
3295
3315
self._notify_about_instance_usage(context, instance,
@@ -3298,7 +3318,8 @@ def _notify_instance_rebuild_error(self, context, instance, error, bdms):
3298
3318
context, instance, self.host,
3299
3319
phase=fields.NotificationPhase.ERROR, exception=error, bdms=bdms)
3300
3320
3301
- @messaging.expected_exceptions(exception.PreserveEphemeralNotSupported)
3321
+ @messaging.expected_exceptions(exception.PreserveEphemeralNotSupported,
3322
+ exception.BuildAbortException)
3302
3323
@wrap_exception()
3303
3324
@reverts_task_state
3304
3325
@wrap_instance_event(prefix='compute')
@@ -3307,7 +3328,7 @@ def rebuild_instance(self, context, instance, orig_image_ref, image_ref,
3307
3328
injected_files, new_pass, orig_sys_metadata,
3308
3329
bdms, recreate, on_shared_storage,
3309
3330
preserve_ephemeral, migration,
3310
- scheduled_node, limits, request_spec):
3331
+ scheduled_node, limits, request_spec, accel_uuids ):
3311
3332
"""Destroy and re-make this instance.
3312
3333
3313
3334
A 'rebuild' effectively purges all existing data from the system and
@@ -3338,6 +3359,7 @@ def rebuild_instance(self, context, instance, orig_image_ref, image_ref,
3338
3359
:param limits: Overcommit limits set by the scheduler. If a host was
3339
3360
specified by the user, this will be None
3340
3361
:param request_spec: a RequestSpec object used to schedule the instance
3362
+ :param accel_uuids: a list of cyborg ARQ uuids.
3341
3363
3342
3364
"""
3343
3365
# recreate=True means the instance is being evacuated from a failed
@@ -3402,7 +3424,7 @@ def rebuild_instance(self, context, instance, orig_image_ref, image_ref,
3402
3424
image_meta, injected_files, new_pass, orig_sys_metadata,
3403
3425
bdms, evacuate, on_shared_storage, preserve_ephemeral,
3404
3426
migration, request_spec, allocs, rebuild_claim,
3405
- scheduled_node, limits)
3427
+ scheduled_node, limits, accel_uuids )
3406
3428
except (exception.ComputeResourcesUnavailable,
3407
3429
exception.RescheduledException) as e:
3408
3430
if isinstance(e, exception.ComputeResourcesUnavailable):
@@ -3469,7 +3491,7 @@ def _do_rebuild_instance_with_claim(
3469
3491
self, context, instance, orig_image_ref, image_meta,
3470
3492
injected_files, new_pass, orig_sys_metadata, bdms, evacuate,
3471
3493
on_shared_storage, preserve_ephemeral, migration, request_spec,
3472
- allocations, rebuild_claim, scheduled_node, limits):
3494
+ allocations, rebuild_claim, scheduled_node, limits, accel_uuids ):
3473
3495
"""Helper to avoid deep nesting in the top-level method."""
3474
3496
3475
3497
provider_mapping = None
@@ -3490,7 +3512,7 @@ def _do_rebuild_instance_with_claim(
3490
3512
context, instance, orig_image_ref, image_meta, injected_files,
3491
3513
new_pass, orig_sys_metadata, bdms, evacuate, on_shared_storage,
3492
3514
preserve_ephemeral, migration, request_spec, allocations,
3493
- provider_mapping)
3515
+ provider_mapping, accel_uuids )
3494
3516
3495
3517
@staticmethod
3496
3518
def _get_image_name(image_meta):
@@ -3499,12 +3521,12 @@ def _get_image_name(image_meta):
3499
3521
else:
3500
3522
return ''
3501
3523
3502
- def _do_rebuild_instance(self, context, instance, orig_image_ref,
3503
- image_meta, injected_files, new_pass ,
3504
- orig_sys_metadata, bdms, evacuate,
3505
- on_shared_storage, preserve_ephemeral,
3506
- migration, request_spec, allocations ,
3507
- request_group_resource_providers_mapping ):
3524
+ def _do_rebuild_instance(
3525
+ self, context, instance, orig_image_ref, image_meta ,
3526
+ injected_files, new_pass, orig_sys_metadata, bdms, evacuate,
3527
+ on_shared_storage, preserve_ephemeral, migration, request_spec ,
3528
+ allocations, request_group_resource_providers_mapping ,
3529
+ accel_uuids ):
3508
3530
orig_vm_state = instance.vm_state
3509
3531
3510
3532
if evacuate:
@@ -3645,7 +3667,8 @@ def detach_block_devices(context, bdms):
3645
3667
block_device_info=block_device_info,
3646
3668
network_info=network_info,
3647
3669
preserve_ephemeral=preserve_ephemeral,
3648
- evacuate=evacuate)
3670
+ evacuate=evacuate,
3671
+ accel_uuids=accel_uuids)
3649
3672
try:
3650
3673
with instance.mutated_migration_context():
3651
3674
self.driver.rebuild(**kwargs)
0 commit comments