Skip to content

Commit 98e9989

Browse files
committed
Heal PCI allocation during resize
During resize an instance with existing PCI allocation can be changed to consume less, more, or different PCI devices. So the heal allocation logic needs to handle the case when an existing instance is changed to consume different PCI devices. This patch adds support to change existing PCI allocations in placement during resize. There is one limitation of the healing logic. It assumes that there is no in-progress migration when nova is upgraded. If there is an in progress migration, then the PCI usage will not be healed in the migration allocation. The placement view will be consistent after such migration is completed or reverted. blueprint: pci-device-tracking-in-placement Change-Id: Icc968c567f9967d7449d6c6c1f57783098e63f55
1 parent d483a69 commit 98e9989

File tree

3 files changed

+445
-0
lines changed

3 files changed

+445
-0
lines changed

doc/source/admin/pci-passthrough.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,4 +394,14 @@ be added to the resource provider representing the matching PCI devices.
394394
(Zed) the nova-compute service will refuse to start with such configuration.
395395
It is suggested to use the PCI address of the device instead.
396396

397+
The nova-compute service makes sure that already existing instances with PCI
398+
allocations in the nova DB will have a corresponding PCI allocation in
399+
placement. This allocation healing also acts on any new instances regardless of
400+
the status of the scheduling part of this feature to make sure that the nova
401+
DB and placement are in sync. There is one limitation of the healing logic.
402+
It assumes that there is no in-progress migration when the nova-compute service
403+
is upgraded. If there is an in-progress migration, then the PCI allocation on
404+
the source host of the migration will not be healed. The placement view will be
405+
consistent after such migration is completed or reverted.
406+
397407
For deeper technical details please read the `nova specification. <https://specs.openstack.org/openstack/nova-specs/specs/zed/approved/pci-device-tracking-in-placement.html>`_

nova/compute/pci_placement_translator.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,31 @@ def update_allocations(
268268
rp_uuid = provider_tree.data(self.name).uuid
269269

270270
for consumer, amount in self._get_allocations().items():
271+
if consumer not in allocations:
272+
# We have PCI device(s) allocated to an instance, but we don't
273+
# see any instance allocation in placement. This
274+
# happens for two reasons:
275+
# 1) The instance is being migrated and therefore the
276+
# allocation is held by the migration UUID in placement. In
277+
# this case the PciDevice is still allocated to the instance
278+
# UUID in the nova DB hence our lookup for the instance
279+
# allocation here. We can ignore this case as: i) We healed
280+
# the PCI allocation for the instance before the migration
281+
# was started. ii) Nova simply moves the allocation from the
282+
# instance UUID to the migration UUID in placement. So we
283+
# assume the migration allocation is correct without
284+
# healing. One limitation of this is that if there is in
285+
# progress migration when nova is upgraded, then the PCI
286+
# allocation of that migration will be missing from
287+
# placement on the source host. But it is temporary and the
288+
# allocation will be fixed as soon as the migration is
289+
# completed or reverted.
290+
# 2) We have a bug in the scheduler or placement and the whole
291+
# instance allocation is lost. We cannot handle that here.
292+
# It is expected to be healed via nova-manage placement
293+
# heal_allocation CLI instead.
294+
continue
295+
271296
current_allocs = allocations[consumer]['allocations']
272297
current_rp_allocs = current_allocs.get(rp_uuid)
273298

0 commit comments

Comments
 (0)