Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor vmref resolution #268

Draft
wants to merge 8 commits into
base: stable/rocky-m3
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion nova/compute/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2454,7 +2454,8 @@ def get(self, context, instance_id, expected_attrs=None):
except exception.InvalidID:
LOG.debug("Invalid instance id %s", instance_id)
raise exception.InstanceNotFound(instance_id=instance_id)

context.resource_id = instance.uuid
context.update_store()
return instance

def get_all(self, context, search_opts=None, limit=None, marker=None,
Expand Down
6 changes: 6 additions & 0 deletions nova/compute/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1952,6 +1952,9 @@ def build_and_run_instance(self, context, instance, image, request_spec,

@utils.synchronized(instance.uuid)
def _locked_do_build_and_run_instance(*args, **kwargs):
# NOTE(fwiesel): Spawned in a different thread, store the context
context.update_store()

# NOTE(danms): We grab the semaphore with the instance uuid
# locked because we could wait in line to build this instance
# for a while and we want to make sure that nothing else tries
Expand Down Expand Up @@ -7929,6 +7932,9 @@ def _sync_power_states(self, context):
'num_vm_instances': num_vm_instances})

def _sync(db_instance):
context.resource_uuid = db_instance.uuid
context.update_store()

# NOTE(melwitt): This must be synchronized as we query state from
# two separate sources, the driver and the database.
# They are set (in stop_instance) and read, in sync.
Expand Down
8 changes: 6 additions & 2 deletions nova/conductor/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,8 @@ def build_instances(self, context, instances, image, filter_properties,

elevated = context.elevated()
for (instance, host_list) in six.moves.zip(instances, host_lists):
context.resource_uuid = instance.uuid
context.update_store()
host = host_list.pop(0)
if is_reschedule:
# If this runs in the superconductor, the first instance will
Expand Down Expand Up @@ -774,7 +776,7 @@ def build_instances(self, context, instances, image, filter_properties,

alts = [(alt.service_host, alt.nodename) for alt in host_list]
LOG.debug("Selected host: %s; Selected node: %s; Alternates: %s",
host.service_host, host.nodename, alts, instance=instance)
host.service_host, host.nodename, alts)

self.compute_rpcapi.build_and_run_instance(context,
instance=instance, host=host.service_host, image=image,
Expand Down Expand Up @@ -1374,13 +1376,15 @@ def schedule_and_build_instances(self, context, build_requests,
# Skip placeholders that were buried in cell0 or had their
# build requests deleted by the user before instance create.
continue
context.resource_uuid = instance.uuid
context.update_store()
cell = cell_mapping_cache[instance.uuid]
# host_list is a list of one or more Selection objects, the first
# of which has been selected and its resources claimed.
host = host_list.pop(0)
alts = [(alt.service_host, alt.nodename) for alt in host_list]
LOG.debug("Selected host: %s; Selected node: %s; Alternates: %s",
host.service_host, host.nodename, alts, instance=instance)
host.service_host, host.nodename, alts)
filter_props = request_spec.to_legacy_filter_properties_dict()
scheduler_utils.populate_retry(filter_props, instance.uuid)
scheduler_utils.populate_filter_properties(filter_props,
Expand Down
Loading