Skip to content

Commit 279aa24

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Fix aggregate placement sync issue"
2 parents c6d6907 + eb433bf commit 279aa24

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
@@ -6029,9 +6029,11 @@ def add_host_to_aggregate(self, context, aggregate_id, host_name):
60296029

60306030
aggregate.add_host(host_name)
60316031
self.query_client.update_aggregates(context, [aggregate])
6032+
nodes = objects.ComputeNodeList.get_all_by_host(context, host_name)
6033+
node_name = nodes[0].hypervisor_hostname
60326034
try:
60336035
self.placement_client.aggregate_add_host(
6034-
context, aggregate.uuid, host_name=host_name)
6036+
context, aggregate.uuid, host_name=node_name)
60356037
except (exception.ResourceProviderNotFound,
60366038
exception.ResourceProviderAggregateRetrievalFailed,
60376039
exception.ResourceProviderUpdateFailed,
@@ -6045,7 +6047,7 @@ def add_host_to_aggregate(self, context, aggregate_id, host_name):
60456047
LOG.warning("Failed to associate %s with a placement "
60466048
"aggregate: %s. This may be corrected after running "
60476049
"nova-manage placement sync_aggregates.",
6048-
host_name, err)
6050+
node_name, err)
60496051
self._update_az_cache_for_host(context, host_name, aggregate.metadata)
60506052
# NOTE(jogo): Send message to host to support resource pools
60516053
self.compute_rpcapi.add_aggregate_host(context,
@@ -6083,19 +6085,21 @@ def remove_host_from_aggregate(self, context, aggregate_id, host_name):
60836085
# we change anything on the nova side because if we did the nova stuff
60846086
# first we can't re-attempt this from the compute API if cleaning up
60856087
# placement fails.
6088+
nodes = objects.ComputeNodeList.get_all_by_host(context, host_name)
6089+
node_name = nodes[0].hypervisor_hostname
60866090
try:
60876091
# Anything else this raises is handled in the route handler as
60886092
# either a 409 (ResourceProviderUpdateConflict) or 500.
60896093
self.placement_client.aggregate_remove_host(
6090-
context, aggregate.uuid, host_name)
6094+
context, aggregate.uuid, node_name)
60916095
except exception.ResourceProviderNotFound as err:
60926096
# If the resource provider is not found then it's likely not part
60936097
# of the aggregate anymore anyway since provider aggregates are
60946098
# not resources themselves with metadata like nova aggregates, they
60956099
# are just a grouping concept around resource providers. Log and
60966100
# continue.
60976101
LOG.warning("Failed to remove association of %s with a placement "
6098-
"aggregate: %s.", host_name, err)
6102+
"aggregate: %s.", node_name, err)
60996103

61006104
aggregate.delete_host(host_name)
61016105
self.query_client.update_aggregates(context, [aggregate])

0 commit comments

Comments
 (0)