Skip to content

Commit eb433bf

Browse files
committed
Fix aggregate placement sync issue
Use node name to sync the nova aggregate to placement resource provider aggregate. Change-Id: I08f2f07c0c695d1dd5b4fa72d0155e02b1872b0a closes-bug: #1877229
1 parent 4b62c90 commit eb433bf

File tree

4 files changed

+183
-28
lines changed

4 files changed

+183
-28
lines changed

nova/compute/api.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6031,9 +6031,11 @@ def add_host_to_aggregate(self, context, aggregate_id, host_name):
60316031

60326032
aggregate.add_host(host_name)
60336033
self.query_client.update_aggregates(context, [aggregate])
6034+
nodes = objects.ComputeNodeList.get_all_by_host(context, host_name)
6035+
node_name = nodes[0].hypervisor_hostname
60346036
try:
60356037
self.placement_client.aggregate_add_host(
6036-
context, aggregate.uuid, host_name=host_name)
6038+
context, aggregate.uuid, host_name=node_name)
60376039
except (exception.ResourceProviderNotFound,
60386040
exception.ResourceProviderAggregateRetrievalFailed,
60396041
exception.ResourceProviderUpdateFailed,
@@ -6047,7 +6049,7 @@ def add_host_to_aggregate(self, context, aggregate_id, host_name):
60476049
LOG.warning("Failed to associate %s with a placement "
60486050
"aggregate: %s. This may be corrected after running "
60496051
"nova-manage placement sync_aggregates.",
6050-
host_name, err)
6052+
node_name, err)
60516053
self._update_az_cache_for_host(context, host_name, aggregate.metadata)
60526054
# NOTE(jogo): Send message to host to support resource pools
60536055
self.compute_rpcapi.add_aggregate_host(context,
@@ -6085,19 +6087,21 @@ def remove_host_from_aggregate(self, context, aggregate_id, host_name):
60856087
# we change anything on the nova side because if we did the nova stuff
60866088
# first we can't re-attempt this from the compute API if cleaning up
60876089
# placement fails.
6090+
nodes = objects.ComputeNodeList.get_all_by_host(context, host_name)
6091+
node_name = nodes[0].hypervisor_hostname
60886092
try:
60896093
# Anything else this raises is handled in the route handler as
60906094
# either a 409 (ResourceProviderUpdateConflict) or 500.
60916095
self.placement_client.aggregate_remove_host(
6092-
context, aggregate.uuid, host_name)
6096+
context, aggregate.uuid, node_name)
60936097
except exception.ResourceProviderNotFound as err:
60946098
# If the resource provider is not found then it's likely not part
60956099
# of the aggregate anymore anyway since provider aggregates are
60966100
# not resources themselves with metadata like nova aggregates, they
60976101
# are just a grouping concept around resource providers. Log and
60986102
# continue.
60996103
LOG.warning("Failed to remove association of %s with a placement "
6100-
"aggregate: %s.", host_name, err)
6104+
"aggregate: %s.", node_name, err)
61016105

61026106
aggregate.delete_host(host_name)
61036107
self.query_client.update_aggregates(context, [aggregate])

0 commit comments

Comments
 (0)