Skip to content

Commit

Permalink
WIP: Cold-Migrate/Resize with multiple nodes
Browse files Browse the repository at this point in the history
The driver and scheduler support conceptually multiple nodes
per compute host, but the resize api assumes a single node
per host as the only case of multiple nodes per host is ironic,
which does not support resizing or migration for obvious reasons.

This removes the assumption to fix resize/cold-migration on
hypervisors, which may support it (eventually vmware)

Change-Id: I9200dfea623458865f289c25fa5fb06a2140b1cb
  • Loading branch information
fwiesel committed Oct 25, 2023
1 parent f726ade commit 401e8c4
Showing 1 changed file with 17 additions and 21 deletions.
38 changes: 17 additions & 21 deletions nova/compute/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4015,14 +4015,13 @@ def _validate_host_for_cold_migrate(
raise exception.ComputeHostNotFound(host=host_name)

with nova_context.target_cell(context, hm.cell_mapping) as cctxt:
node = objects.ComputeNode.\
get_first_node_by_host_for_old_compat(
cctxt, host_name, use_slave=True)
nodes = objects.ComputeNodeList.get_all_by_host(
cctxt, host_name, use_slave=True)
else:
node = objects.ComputeNode.get_first_node_by_host_for_old_compat(
nodes = objects.ComputeNodeList.get_all_by_host(
context, host_name, use_slave=True)

return node
return nodes

# TODO(stephenfin): This logic would be so much easier to grok if we
# finally split resize and cold migration into separate code paths
Expand Down Expand Up @@ -4050,8 +4049,10 @@ def resize(self, context, instance, flavor_id=None, clean_shutdown=True,
context, instance)

if host_name is not None:
node = self._validate_host_for_cold_migrate(
nodes = self._validate_host_for_cold_migrate(
context, instance, host_name, allow_cross_cell_resize)
else:
nodes = None

self._check_auto_disk_config(
instance, auto_disk_config=auto_disk_config)
Expand All @@ -4076,9 +4077,8 @@ def resize(self, context, instance, flavor_id=None, clean_shutdown=True,
if CONF.always_resize_on_same_host:
LOG.info('Setting resize to the same host')
host_name = instance.host
node = (
objects.ComputeNode.get_first_node_by_host_for_old_compat(
context, host_name, use_slave=True))
nodes = objects.ComputeNodeList.get_all_by_host(
context, host_name, use_slave=True)
new_flavor = flavors.get_flavor_by_flavor_id(
flavor_id, read_deleted="no")
# NOTE(wenping): We use this instead of the 'block_accelerator'
Expand Down Expand Up @@ -4189,20 +4189,16 @@ def resize(self, context, instance, flavor_id=None, clean_shutdown=True,
# which takes has filter_properties which in turn has
# scheduler_hints (plural).

if host_name is None:
# If 'host_name' is not specified,
# clear the 'requested_destination' field of the RequestSpec
# except set the allow_cross_cell_move flag since conductor uses
# it prior to scheduling.
request_spec.requested_destination = objects.Destination(
allow_cross_cell_move=allow_cross_cell_resize)
if nodes and len(nodes) == 1:
node_name = nodes[0].hypervisor_hostname
else:
# Set the host and the node so that the scheduler will
# validate them.
request_spec.requested_destination = objects.Destination(
host=node.host, node=node.hypervisor_hostname,
allow_cross_cell_move=allow_cross_cell_resize)
node_name = None

# Set the host and the node so that the scheduler will either
# validate them, or select one matching host and potentially node
request_spec.requested_destination = objects.Destination(
host=host_name, node=node_name,
allow_cross_cell_move=allow_cross_cell_resize)
# Asynchronously RPC cast to conductor so the response is not blocked
# during scheduling. If something fails the user can find out via
# instance actions.
Expand Down

0 comments on commit 401e8c4

Please sign in to comment.