Skip to content

Commit a0e60fe

Browse files
Balazs Gibizermriedem
authored andcommitted
Add request_spec to server move RPC calls
To be able to fill the allocation key in the port binding:profile during the move operations the nova-compute needs to get the RequestSpec object to have access to the port - resource provider mapping calculated in the conductor. This patch bumps the compute RPC api version and adds a new request_spec parameter to multiple calls. Also it makes sure that the request_spec is passed by the sender. Change-Id: If1f465112b8e9b0304b8b5b864b985f72168d839 blueprint: support-move-ops-with-qos-ports
1 parent a413150 commit a0e60fe

File tree

11 files changed

+221
-93
lines changed

11 files changed

+221
-93
lines changed

nova/compute/api.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3456,7 +3456,8 @@ def revert_resize(self, context, instance):
34563456
# by compute.
34573457
self.compute_rpcapi.revert_resize(context, instance,
34583458
migration,
3459-
migration.dest_compute)
3459+
migration.dest_compute,
3460+
reqspec)
34603461

34613462
@check_instance_lock
34623463
@check_instance_state(vm_state=[vm_states.RESIZED])

nova/compute/manager.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ def update_compute_provider_status(self, context, rp_uuid, enabled):
519519
class ComputeManager(manager.Manager):
520520
"""Manages the running instances from creation to destruction."""
521521

522-
target = messaging.Target(version='5.1')
522+
target = messaging.Target(version='5.2')
523523

524524
def __init__(self, compute_driver=None, *args, **kwargs):
525525
"""Load configuration options and connect to the hypervisor."""
@@ -4148,7 +4148,7 @@ def _delete_allocation_after_move(self, context, instance, migration):
41484148
@wrap_instance_event(prefix='compute')
41494149
@errors_out_migration
41504150
@wrap_instance_fault
4151-
def revert_resize(self, context, instance, migration):
4151+
def revert_resize(self, context, instance, migration, request_spec=None):
41524152
"""Destroys the new instance on the destination machine.
41534153
41544154
Reverts the model changes, and powers on the old instance on the
@@ -4201,7 +4201,7 @@ def revert_resize(self, context, instance, migration):
42014201

42024202
# RPC cast back to the source host to finish the revert there.
42034203
self.compute_rpcapi.finish_revert_resize(context, instance,
4204-
migration, migration.source_compute)
4204+
migration, migration.source_compute, request_spec)
42054205

42064206
def _finish_revert_resize_network_migrate_finish(self, context, instance,
42074207
migration):
@@ -4251,7 +4251,8 @@ def _finish_revert_resize_network_migrate_finish(self, context, instance,
42514251
@wrap_instance_event(prefix='compute')
42524252
@errors_out_migration
42534253
@wrap_instance_fault
4254-
def finish_revert_resize(self, context, instance, migration):
4254+
def finish_revert_resize(
4255+
self, context, instance, migration, request_spec=None):
42554256
"""Finishes the second half of reverting a resize on the source host.
42564257
42574258
Bring the original source instance state back (active/shutoff) and
@@ -4383,7 +4384,8 @@ def _revert_allocation(self, context, instance, migration):
43834384
return True
43844385

43854386
def _prep_resize(self, context, image, instance, instance_type,
4386-
filter_properties, node, migration, clean_shutdown=True):
4387+
filter_properties, node, migration, request_spec,
4388+
clean_shutdown=True):
43874389

43884390
if not filter_properties:
43894391
filter_properties = {}
@@ -4424,7 +4426,7 @@ def _prep_resize(self, context, image, instance, instance_type,
44244426
# RPC cast to the source host to start the actual resize/migration.
44254427
self.compute_rpcapi.resize_instance(
44264428
context, instance, claim.migration, image,
4427-
instance_type, clean_shutdown)
4429+
instance_type, request_spec, clean_shutdown)
44284430

44294431
def _send_prep_resize_notifications(
44304432
self, context, instance, phase, flavor):
@@ -4491,7 +4493,8 @@ def prep_resize(self, context, image, instance, instance_type,
44914493
try:
44924494
self._prep_resize(context, image, instance,
44934495
instance_type, filter_properties,
4494-
node, migration, clean_shutdown)
4496+
node, migration, request_spec,
4497+
clean_shutdown)
44954498
except Exception:
44964499
# Since we hit a failure, we're either rescheduling or dead
44974500
# and either way we need to cleanup any allocations created
@@ -4583,21 +4586,23 @@ def _reschedule_resize_or_reraise(self, context, instance, exc_info,
45834586
@wrap_instance_event(prefix='compute')
45844587
@wrap_instance_fault
45854588
def resize_instance(self, context, instance, image,
4586-
migration, instance_type, clean_shutdown):
4589+
migration, instance_type, clean_shutdown,
4590+
request_spec=None):
45874591
"""Starts the migration of a running instance to another host.
45884592
45894593
This is initiated from the destination host's ``prep_resize`` routine
45904594
and runs on the source host.
45914595
"""
45924596
try:
45934597
self._resize_instance(context, instance, image, migration,
4594-
instance_type, clean_shutdown)
4598+
instance_type, clean_shutdown, request_spec)
45954599
except Exception:
45964600
with excutils.save_and_reraise_exception():
45974601
self._revert_allocation(context, instance, migration)
45984602

45994603
def _resize_instance(self, context, instance, image,
4600-
migration, instance_type, clean_shutdown):
4604+
migration, instance_type, clean_shutdown,
4605+
request_spec):
46014606
with self._error_out_instance_on_exception(context, instance), \
46024607
errors_out_migration_ctxt(migration):
46034608
network_info = self.network_api.get_instance_nw_info(context,
@@ -4643,7 +4648,8 @@ def _resize_instance(self, context, instance, image,
46434648

46444649
# RPC cast to the destination host to finish the resize/migration.
46454650
self.compute_rpcapi.finish_resize(context, instance,
4646-
migration, image, disk_info, migration.dest_compute)
4651+
migration, image, disk_info, migration.dest_compute,
4652+
request_spec)
46474653

46484654
self._send_resize_instance_notifications(
46494655
context, instance, bdms, network_info,
@@ -4835,7 +4841,7 @@ def _finish_resize(self, context, instance, migration, disk_info,
48354841
@errors_out_migration
48364842
@wrap_instance_fault
48374843
def finish_resize(self, context, disk_info, image, instance,
4838-
migration):
4844+
migration, request_spec=None):
48394845
"""Completes the migration process.
48404846
48414847
Sets up the newly transferred disk and turns on the instance at its
@@ -5353,7 +5359,7 @@ def _shelve_offload_instance(self, context, instance, clean_shutdown,
53535359
@wrap_instance_event(prefix='compute')
53545360
@wrap_instance_fault
53555361
def unshelve_instance(self, context, instance, image,
5356-
filter_properties, node):
5362+
filter_properties, node, request_spec=None):
53575363
"""Unshelve the instance.
53585364
53595365
:param context: request context
@@ -5362,6 +5368,8 @@ def unshelve_instance(self, context, instance, image,
53625368
volume backed instance.
53635369
:param filter_properties: dict containing limits, retry info etc.
53645370
:param node: target compute node
5371+
:param request_spec: the RequestSpec object used to schedule the
5372+
instance
53655373
"""
53665374
if filter_properties is None:
53675375
filter_properties = {}

nova/compute/rpcapi.py

Lines changed: 69 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,9 @@ class ComputeAPI(object):
364364
* 5.0 - Remove 4.x compatibility
365365
* 5.1 - Make prep_resize() take a RequestSpec object rather than a
366366
legacy dict.
367+
* 5.2 - Add request_spec parameter for the following: resize_instance,
368+
finish_resize, revert_resize, finish_revert_resize,
369+
unshelve_instance
367370
'''
368371

369372
VERSION_ALIASES = {
@@ -596,22 +599,45 @@ def detach_volume(self, ctxt, instance, volume_id, attachment_id=None):
596599
instance=instance, volume_id=volume_id,
597600
attachment_id=attachment_id)
598601

599-
def finish_resize(self, ctxt, instance, migration, image, disk_info, host):
602+
def finish_resize(self, ctxt, instance, migration, image, disk_info, host,
603+
request_spec):
604+
msg_args = {
605+
'instance': instance,
606+
'migration': migration,
607+
'image': image,
608+
'disk_info': disk_info,
609+
'request_spec': request_spec,
610+
}
611+
600612
client = self.router.client(ctxt)
601-
version = '5.0'
613+
version = '5.2'
614+
615+
if not client.can_send_version(version):
616+
msg_args.pop('request_spec')
617+
version = '5.0'
618+
602619
cctxt = client.prepare(
603620
server=host, version=version)
604-
cctxt.cast(ctxt, 'finish_resize',
605-
instance=instance, migration=migration,
606-
image=image, disk_info=disk_info)
621+
cctxt.cast(ctxt, 'finish_resize', **msg_args)
622+
623+
def finish_revert_resize(self, ctxt, instance, migration, host,
624+
request_spec):
625+
msg_args = {
626+
'instance': instance,
627+
'migration': migration,
628+
'request_spec': request_spec,
629+
}
607630

608-
def finish_revert_resize(self, ctxt, instance, migration, host):
609631
client = self.router.client(ctxt)
610-
version = '5.0'
632+
version = '5.2'
633+
634+
if not client.can_send_version(version):
635+
msg_args.pop('request_spec')
636+
version = '5.0'
637+
611638
cctxt = client.prepare(
612639
server=host, version=version)
613-
cctxt.cast(ctxt, 'finish_revert_resize',
614-
instance=instance, migration=migration)
640+
cctxt.cast(ctxt, 'finish_revert_resize', **msg_args)
615641

616642
def get_console_output(self, ctxt, instance, tail_length):
617643
version = '5.0'
@@ -882,14 +908,20 @@ def reset_network(self, ctxt, instance):
882908
cctxt.cast(ctxt, 'reset_network', instance=instance)
883909

884910
def resize_instance(self, ctxt, instance, migration, image, instance_type,
885-
clean_shutdown=True):
911+
request_spec, clean_shutdown=True):
886912
msg_args = {'instance': instance, 'migration': migration,
887913
'image': image,
888914
'instance_type': instance_type,
889915
'clean_shutdown': clean_shutdown,
916+
'request_spec': request_spec,
890917
}
891-
version = '5.0'
918+
version = '5.2'
892919
client = self.router.client(ctxt)
920+
921+
if not client.can_send_version(version):
922+
msg_args.pop('request_spec')
923+
version = '5.0'
924+
893925
cctxt = client.prepare(server=_compute_host(None, instance),
894926
version=version)
895927
cctxt.cast(ctxt, 'resize_instance', **msg_args)
@@ -900,13 +932,24 @@ def resume_instance(self, ctxt, instance):
900932
server=_compute_host(None, instance), version=version)
901933
cctxt.cast(ctxt, 'resume_instance', instance=instance)
902934

903-
def revert_resize(self, ctxt, instance, migration, host):
935+
def revert_resize(self, ctxt, instance, migration, host, request_spec):
936+
937+
msg_args = {
938+
'instance': instance,
939+
'migration': migration,
940+
'request_spec': request_spec,
941+
}
942+
904943
client = self.router.client(ctxt)
905-
version = '5.0'
944+
version = '5.2'
945+
946+
if not client.can_send_version(version):
947+
msg_args.pop('request_spec')
948+
version = '5.0'
949+
906950
cctxt = client.prepare(
907951
server=_compute_host(host, instance), version=version)
908-
cctxt.cast(ctxt, 'revert_resize',
909-
instance=instance, migration=migration)
952+
cctxt.cast(ctxt, 'revert_resize', **msg_args)
910953

911954
def rollback_live_migration_at_destination(self, ctxt, instance, host,
912955
destroy_disks,
@@ -1052,16 +1095,24 @@ def shelve_offload_instance(self, ctxt, instance,
10521095
cctxt.cast(ctxt, 'shelve_offload_instance', instance=instance,
10531096
clean_shutdown=clean_shutdown)
10541097

1055-
def unshelve_instance(self, ctxt, instance, host, image=None,
1098+
def unshelve_instance(self, ctxt, instance, host, request_spec, image=None,
10561099
filter_properties=None, node=None):
1057-
version = '5.0'
1100+
version = '5.2'
10581101
msg_kwargs = {
10591102
'instance': instance,
10601103
'image': image,
10611104
'filter_properties': filter_properties,
10621105
'node': node,
1106+
'request_spec': request_spec,
10631107
}
1064-
cctxt = self.router.client(ctxt).prepare(
1108+
1109+
client = self.router.client(ctxt)
1110+
1111+
if not client.can_send_version(version):
1112+
msg_kwargs.pop('request_spec')
1113+
version = '5.0'
1114+
1115+
cctxt = client.prepare(
10651116
server=host, version=version)
10661117
cctxt.cast(ctxt, 'unshelve_instance', **msg_kwargs)
10671118

nova/conductor/manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -902,8 +902,8 @@ def safe_image_show(ctx, image_id):
902902
availability_zones.get_host_availability_zone(
903903
context, host))
904904
self.compute_rpcapi.unshelve_instance(
905-
context, instance, host, image=image,
906-
filter_properties=filter_properties, node=node)
905+
context, instance, host, request_spec, image=image,
906+
filter_properties=filter_properties, node=node)
907907
except (exception.NoValidHost,
908908
exception.UnsupportedPolicyException):
909909
instance.task_state = None

nova/objects/service.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232

3333
# NOTE(danms): This is the global service version counter
34-
SERVICE_VERSION = 38
34+
SERVICE_VERSION = 39
3535

3636

3737
# NOTE(danms): This is our SERVICE_VERSION history. The idea is that any
@@ -153,6 +153,9 @@
153153
{'compute_rpc': '5.1'},
154154
# Version 38: set_host_enabled reflects COMPUTE_STATUS_DISABLED trait
155155
{'compute_rpc': '5.1'},
156+
# Version 39: resize_instance, finish_resize, revert_resize,
157+
# finish_revert_resize, unshelve_instance takes a RequestSpec object
158+
{'compute_rpc': '5.2'},
156159
)
157160

158161

0 commit comments

Comments
 (0)