From fef371a425d603e184f22d3b630b2c3bd27c7cae Mon Sep 17 00:00:00 2001 From: Balazs Gibizer Date: Tue, 23 Feb 2021 15:02:06 +0100 Subject: [PATCH] Follow up for QoS interface attach This patch fixes minor comments from Id4684093e8bdf3b61667490443e3d2f6ed65f4b3 Change-Id: I6e70e24d837b6f194972386a32ad757ce25dcee0 Blueprint: support-interface-attach-with-qos-ports --- nova/compute/manager.py | 7 +++++++ nova/scheduler/client/report.py | 4 +++- nova/tests/functional/test_servers.py | 16 +++++++++++++--- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/nova/compute/manager.py b/nova/compute/manager.py index a78bbdfc450c..0beedeea9de7 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -7602,6 +7602,13 @@ class ComputeManager(manager.Manager): if not request_groups: return None, None + # NOTE(gibi): we assume a single RequestGroup here as: + # 1) there can only be a single port per interface attach request + # 2) a single port can only request resources in a single RequestGroup + # as per the current neutron API. + # #2) might change in the future so both + # nova.network.neutron.API.create_resource_requests() and this function + # takes a list of groups request_group = request_groups[0] # restrict the resource request to the current compute node. The diff --git a/nova/scheduler/client/report.py b/nova/scheduler/client/report.py index da195bdc112e..95682e2d2061 100644 --- a/nova/scheduler/client/report.py +++ b/nova/scheduler/client/report.py @@ -1755,7 +1755,9 @@ class SchedulerReportClient(object): context, consumer_uuid, resources): error_reason = _("Cannot remove resources %s from the allocation " "due to multiple successive generation conflicts " - "in placement.") + "in placement. To clean up the leaked resource " + "allocation you can use nova-manage placement " + "audit.") raise exception.AllocationUpdateFailed( consumer_uuid=consumer_uuid, error=error_reason % resources) diff --git a/nova/tests/functional/test_servers.py b/nova/tests/functional/test_servers.py index 2371af771a92..b3b155ff3400 100644 --- a/nova/tests/functional/test_servers.py +++ b/nova/tests/functional/test_servers.py @@ -6406,13 +6406,23 @@ class PortResourceRequestBasedSchedulingTest( self.assertComputeAllocationMatchesFlavor( allocations, self.compute1_rp_uuid, self.flavor) - sriov_allocations = allocations[ - self.sriov_dev_rp_per_host[ - self.compute1_rp_uuid][self.PF2]]['resources'] + sriov_dev_rp = self.sriov_dev_rp_per_host[ + self.compute1_rp_uuid][self.PF2] + sriov_allocations = allocations[sriov_dev_rp]['resources'] # this is the leaked allocation in placement self.assertPortMatchesAllocation(sriov_port, sriov_allocations) + allocations[sriov_dev_rp].pop('generation') + leaked_allocation = {sriov_dev_rp: allocations[sriov_dev_rp]} + self.assertIn( + f'Failed to update allocations for consumer {server["id"]}. ' + f'Error: Cannot remove resources {leaked_allocation} from the ' + f'allocation due to multiple successive generation conflicts in ' + f'placement. To clean up the leaked resource allocation you can ' + f'use nova-manage placement audit.', + self.stdlog.logger.output) + # We expect that the port binding is not updated with any RP uuid as # the attach failed. sriov_binding = sriov_port['binding:profile']