Generic NVMe driver with secure cleanup¶
https://blueprints.launchpad.net/openstack-cyborg/+spec/generic-nvme-driver-with-secure-cleanup
In OpenStack there are several ways to pass-through generic PCI devices including a dedicated Inspur NVMe Cyborg driver, Nova PCI pass-through and the Cyborg generic PCI driver. None of these existing mechanisms support multi-tenancy when used with NVMe devices nor are suitable for use in a public cloud as a result. Once the instance gets deleted, there is no way to securely erase data from an NVMe device with OpenStack. The same NVMe device gets allocated to another instance without cleanup. This can leak sensitive information between tenants and may cause issues with workloads by hijacking the boot process and compromising the guest. Basically there is no way to manage the life cycle of an NVMe device in OpenStack.
This blueprint proposes a generic Cyborg NVMe driver that manages the whole lifecycle of NVMe devices. It includes always binding a clean NVMe device to a new instance and securely cleaning up the NVMe device after deallocation for reuse.
Problem description¶
OpenStack lacks automated lifecycle management for NVMe devices. When a
Cyborg-managed NVMe device is detached from an instance, tenant data
remains on the device. Without automated sanitization, operators must
manually track device allocation, run nvme sanitize or
nvme write-zeroes commands via SSH after instance deletion, verify cleanup
completion, and ensure devices are not reallocated during cleanup. This
manual process is time-consuming, error-prone, and does not scale.
Additionally, Cyborg’s existing Inspur NVMe driver locks operators into a single hardware vendor. Operators cannot manage NVMe devices from other vendors through Cyborg without vendor-specific driver implementations for each manufacturer.
Cyborg needs a generic NVMe driver that discovers devices from any vendor, manages allocation and binding, and performs automated secure cleanup using NVMe sanitize/zero commands before devices are returned to the available pool.
Use Cases¶
As an operator, I want Cyborg to discover and manage NVMe devices from any vendor without requiring vendor-specific drivers, so I am not locked into a single hardware manufacturer.
As an operator, I want NVMe devices automatically sanitized after instance deletion, so tenant data cannot leak to subsequent instances without manual intervention.
As an operator, I want failed cleanups to block device reallocation, so devices with residual data are never assigned to new tenants.
As an operator, I want to introspect the state of assigned NVMe controllers and filter by state.
As an operator, I want visibility into cleanup status and manual recovery tools, so I can diagnose and resolve stuck cleanup operations.
As a cloud user, I want assurance that my NVMe device contains no data from previous tenants, so my application does not encounter unexpected data corruption or security violations.
Proposed change¶
This blueprint will add a generic NVMe driver (NVMeDriver) as a
standalone driver. It will reuse the init_host() and cleanup(device)
hooks added to the GenericDriver base class in 2026.2. Both hooks
have no-op (pass) defaults so that existing drivers are unaffected.
The Cyborg agent remains driver-type agnostic.
NVMeDriver implements discovery and the lifecycle hooks:
GenericDriver
├── init_host() → no-op (pass); subclasses override
├── discover() → subclasses override
└── cleanup(device) → no-op (pass); subclasses override
NVMeDriver (new, standalone driver)
├── init_host() → validates nvme-cli and RPC requirements,
│ reads persisted state for recovery
├── discover() → sysfs PCI enumeration filtered by device_spec,
│ NVMe capability detection via nvme id-ctrl
└── cleanup(device) → nvme-cli sanitize/zero
Each hook is described in its own section below. Bind and unbind use the common Cyborg conductor process for all device types.
Cyborg will also add an attachment-handle resource to the V2 API, under a new microversion, with list, show and an administrator-only clean action.
Attachment Handle Design¶
The 2026.2 spec introduced Device.device_state to track device cleanup
state.
We moved Device.device_state to the attach handle because allocation
and cleanup happen per assignable resource. A Cyborg Device represents the
physical hardware. It can have multiple deployables, and each deployable
can have multiple attach handles. The bound accelerator request (ARQ)
records the specific handle it was assigned.
Consider a future NVMe controller configuration with independently assignable namespaces. If a VM releases one namespace, its handle must stay unavailable until cleanup succeeds. Other namespaces on the same controller can still be allocated or already in use. One state on the controller or deployable can’t represent those independent lifecycles. The initial NVMe driver has one handle per controller, which is why device-level state appeared sufficient.
AttachHandle.attachment_state records the handle’s lifecycle, as
described in Attachment Handle State Machine. The conductor updates
in_use and attachment_state together when allocating or releasing
a handle. Device.status records the device’s administrative status
(enabled or maintaining).
Cleanup can fail, and an administrator then needs a way to retry it on the handle that failed. Nothing in the API reports such a handle today: the ARQ that referenced it is deleted along with the instance, and a single state on the device or the deployable cannot point at the one handle that needs cleaning. The attachment handle therefore becomes a resource in its own right, at the top level of the V2 API alongside device and deployable. See REST API impact for the request paths, microversion, response bodies, error codes and policies.
The generic NVMe driver represents each controller as one Cyborg device with one deployable and one attachment handle. For this driver, cleaning the handle means cleaning its controller. The driver establishes this topology during discovery.
NVMe Device Lifecycle Flow¶
The diagram follows an enabled NVMe controller with one attachment handle
and Placement inventory total=1. See Attachment Handle State
Machine for the states and the rule that derives reserved from them.
┌─────────────────────────────────────────────────┐
│ Operator configures cyborg.conf │
│ [agent] enabled_drivers = nvme_driver │
│ [nvme] device_spec = {vendor_id, product_id, │
│ address, clear_action, clear_strategy} │
└─────────────────┬───────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────┐
│ Cyborg agent starts │
│ Checks that nvme-cli is installed │
│ Checks the conductor RPC version cap │
│ Reads persisted state through indirection │
│ Finds the configured NVMe devices │
│ Preserves persisted attachment handle states │
│ Recovers interrupted or missed cleanup │
│ Reports their capacity and features │
│ Selects and records how each device is erased │
└─────────────────┬───────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────┐
│ User creates an instance with an NVMe device │
│ Nova selects an available device │
│ Cyborg binds an available handle to the ARQ │
│ Placement records an allocation │
│ Reserved count stays 0; the attachment handle │
│ is in use │
└─────────────────┬───────────────────────────────┘
│ User deletes instance
▼
┌─────────────────────────────────────────────────┐
│ Nova detaches the device from the instance │
│ The host regains control of the device │
│ Nova asks Cyborg to release it │
└─────────────────┬───────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────┐
│ Conductor marks the attachment handle as │
│ pending cleanup and releases it │
│ The reserved count becomes 1 and the handle │
│ stays unavailable to new instances │
│ Conductor casts clean_attachment_handles │
│ to the agent │
└─────────────────┬───────────────────────────────┘
│
(Nova does not wait for the erase;
instance deletion can finish)
│
▼
┌─────────────────────────────────────────────────┐
│ Cyborg agent: │
│ Receives clean_attachment_handles through the │
│ agent RPC │
│ Records cleaning, then queues cleanup │
│ Resolves the handle's device and asks the │
│ resource tracker for the owning driver, then │
│ calls its cleanup(device) │
│ Driver erases it with the selected method │
│ Stops waiting when the timeout is reached │
│ Requests state update through indirection │
└─────────────┬───────────────────────────────┬───┘
│ SUCCESS │ FAILURE/TIMEOUT
▼ ▼
┌───────────────────────────┐ ┌─────────────────────────────┐
│ Attachment handle is │ │ Attachment handle is │
│ available │ │ unavailable │
│ Reserved count = 0 │ │ Reserved count = 1 │
│ Ready for next VM │ │ The attachment handle is │
│ │ │ in error │
└───────────────────────────┘ └──────────────┬──────────────┘
│ Administrator
│ lists and shows the
│ failed handle, then
│ retries cleanup
▼
┌──────────────────────────────────┐
│ API checks the selected handle, │
│ sets pending_cleaning and casts │
│ clean_attachment_handles │
│ Agent runs the same workflow as │
│ unbind │
└──────────────────────────────────┘
The agent invokes the owning driver locally and uses remotable object methods, which execute on the conductor under the indirection spec [1], to persist lifecycle state and cleanup results; it does not write to the database directly.
After a restart the agent reads its host’s persisted attachment-handle and allocation state the same way and resumes interrupted or missed cleanup, with the handle staying reserved until cleanup succeeds. See Timeout and Crash Recovery.
Scope¶
This spec will cover local NVMe PCI controllers present on the host PCI bus.
Cyborg will discover these controllers and bind their attachment handles to
accelerator requests. After Nova detaches a controller and requests its
release, Cyborg will securely erase it before allowing reuse. Operators
will be able to check the cleanup status of each attachment handle.
Administrators will be able to retry cleanup for handles in the error
state.
init_host¶
NVMeDriver.init_host() will validate that nvme-cli is installed. If
nvme-cli is missing and nvme_driver is enabled, the hook will raise
an exception and prevent the agent from starting.
At startup, the NVMe driver will use object indirection to read persisted device and allocation state, as defined by the Versioned Object Indirection Support spec [1]. The conductor RPC cap must allow object indirection for the driver to start.
The agent will use the persisted state to identify devices requiring recovery, as described in Timeout and Crash Recovery.
Device Discovery¶
The NVMe driver is enabled by adding nvme_driver to
[agent] enabled_drivers and configuring device_spec under the
[nvme] section in cyborg.conf.
Each device_spec entry is a JSON object that selects the NVMe controllers
the NVMe driver manages and sets their cleanup policy. The supported fields
are:
vendor_id: matches the controller’s PCI vendor ID.product_id: matches the controller’s PCI device ID.address: matches the controller’s PCI address, with support for glob and regex patterns.clear_action: selects the cleanup operation. Supported values areauto(default),sanitizeandzero.clear_strategy: selects the erase approach. Supported values areauto(default),cryptoandblock.
When an entry combines vendor_id, product_id or address, a
controller must match every specified selector. clear_action and
clear_strategy are optional and apply to the matched controllers. See
Discovery and Cleanup Resolution for the cleanup policy matrix.
The NVMe driver discovers controllers under /sys/bus/pci/devices/ and
manages those that match a device_spec entry. For example:
[nvme]
device_spec = {"vendor_id": "8086", "product_id": "0001",
"clear_action": "auto", "clear_strategy": "auto"}
# OR
device_spec = {"address": "*:0a:00.*"}
# OR combined
device_spec = {"vendor_id": "8086", "address": "0000:0a:00.*"}
Discovery and Cleanup Resolution¶
During discovery, the NVMe driver resolves the NVMe device path from the
PCI address via sysfs and runs nvme id-ctrl under privsep for each
discovered device. The driver detects hardware capabilities and reports
the supported capabilities to Placement as standard traits for Crypto
Erase Sanitize (CES), Block Erase Sanitize (BES) and Write Zeroes
(WZS). The driver uses Namespace Management support internally.
All hardware capability traits are reported to Placement regardless of the operator-selected cleanup policy. Traits describe what the device supports, not what the configured policy will use.
Cleanup policy is configured per device via the clear_action and
clear_strategy keys in device_spec. clear_action selects
the operation type (sanitize, zero); clear_strategy constrains the
erase mechanism (crypto, block).
clear_action selects the cleanup operation:
auto(default): select an operation during discovery based onclear_strategyand the device capabilities.sanitize: require NVMe sanitize.zero: require block-device clearing by writing zeroes to the full device.
clear_strategy selects the erase approach within the action:
auto(default): choose the strongest supported approach for the selected action.crypto: require cryptographic erase.block: require a non-cryptographic block/media erase or block clear approach.
The policy matrix is:
+--------------+----------------+---------------------------------------+
| clear_action | clear_strategy | selected cleanup operation |
+==============+================+=======================================+
| auto | auto | CES sanitize, else BES sanitize, else |
| | | write zeroes, else shred |
+--------------+----------------+---------------------------------------+
| auto | crypto | CES sanitize only |
+--------------+----------------+---------------------------------------+
| auto | block | BES sanitize, else write zeroes, else |
| | | shred |
+--------------+----------------+---------------------------------------+
| sanitize | auto | CES sanitize, else BES sanitize |
+--------------+----------------+---------------------------------------+
| sanitize | crypto | CES sanitize only |
+--------------+----------------+---------------------------------------+
| sanitize | block | BES sanitize only |
+--------------+----------------+---------------------------------------+
| zero | auto/block | write zeroes, else shred |
+--------------+----------------+---------------------------------------+
| zero | crypto | invalid configuration |
+--------------+----------------+---------------------------------------+
The resolution chain within the zero method prefers nvme
write-zeroes (controller-side, if WZS is supported) over
host-side zeroing via shred, following Nova’s volume_clear
pattern for LVM volumes.
The resolved action is stored in std_board_info alongside existing
device metadata. The selected cleanup action is fixed for the device until
the next discovery cycle or agent restart. There is no runtime fallback.
The cleanup action portion of std_board_info must not be overwritten by
discover() while any attachment handle on the device is in a state
other than available; when an attachment handle is in error the
action may be updated to allow operators to fall back to a different
strategy. If the locked-in cleanup action fails, times out, or cannot be
completed, the attachment handle moves to error.
If the configured policy cannot be satisfied by the discovered device capabilities, the device is not reported as available. The driver logs an error and excludes the device from the available pool until the configuration is corrected or the device is replaced.
Driver Deprecation¶
Cyborg will deprecate the existing SSD and Inspur drivers in this release
in favour of the generic NVMe driver. The deprecated drivers and the new
generic NVMe driver can coexist on the same system as long as they
manage independent devices. For any given device, managing it with more
than one driver simultaneously is considered invalid. The Cyborg agent
already enforces this at startup, raising InvalidConfiguration if
more than one driver returns the same device.
Placement Integration¶
Device type and vendor/product identity are encoded in the resource
class name as CUSTOM_NVME_<VENDOR_ID>_<PRODUCT_ID>, following
the pattern used by Nova’s PCI placement translator which generates
CUSTOM_PCI_<VENDOR_ID>_<PRODUCT_ID>. The existing Cyborg PCI
driver incorrectly encodes vendor and product identity as traits;
instead the NVMe driver follows Nova’s PCI placement translator by
encoding them in the resource class. Traits are reserved for NVMe
capabilities as described in Discovery and Cleanup Resolution.
The NVMe driver’s discover() method builds DriverDevice objects
with type=NVME and reports NVMe capability traits alongside
OWNER_CYBORG. The std_board_info field contains the
product_id and pci_address of the device’s Physical Function
(PF). Resource provider and deployable names use the format
<hostname>_<pci_address>.
For example, an Intel NVMe device on compute-1 at PCI address
0000:01:00.0 that supports crypto erase and block erase would be
registered in Placement as:
Resource provider: compute-1_0000:01:00.0
Resource class: CUSTOM_NVME_8086_0001
Inventory: total=1
Traits: OWNER_CYBORG, HW_NVME_CES, HW_NVME_BES, HW_NVME_WZS
During discovery, if the NVMe driver finds that a resource provider
already exists for a PCI address but does not have the OWNER_CYBORG
trait, the driver logs an error and skips that device. This prevents
conflicts when the same device is also managed by Nova. Nova’s PCI
placement translator uses the same <hostname>_<pci_address> naming
scheme, so a Nova-managed device at the same PCI address would have an
RP with CUSTOM_PCI_<VENDOR_ID>_<PRODUCT_ID> but without OWNER_CYBORG.
Cleanup Policy and Execution¶
The cleanup contract provided by this driver is that a Cyborg-managed NVMe device is cleaned before it is returned to the available pool. The minimum guarantee is clearing the host-addressable block device. This prevents reuse of stale tenant data by the next consumer, but it is not a claim that previous data is unrecoverable with advanced forensic techniques. Tenants that require confidentiality of data at rest should use guest-managed encryption such as LUKS.
When Nova deletes an instance, it calls DELETE
/v2/accelerator_requests. The conductor releases the attachment handle
and, for a device that supports cleaning, dispatches the asynchronous
cleanup workflow described in Attachment Handle State Machine. Cleanup
is serialised per attachment handle, and all nvme-cli commands run under
privsep.
The agent executes exactly the cleanup action that was locked in during discovery (see Discovery and Cleanup Resolution). There is no runtime fallback, and an administrator retry reuses the same action.
NVMe cleanup requires the controller character device (/dev/nvmeN)
to be accessible on the host after the guest is destroyed. Libvirt’s
managed mode handles this: it rebinds the device to the host NVMe
kernel driver on guest teardown. Driver binding is entirely managed
by libvirt; Cyborg assumes the device is already bound to the host
driver when cleanup begins.
Cleanup execution order
For sanitize-based cleanup:
Resolve the NVMe controller device from the PCI address
Check sanitize status; if a previous sanitize is still running, poll it instead of starting a new one
Run the selected sanitize action (sanitize erases the entire controller regardless of how many namespaces exist)
Poll until completion, failure, or timeout
Unless the controller already presents exactly one namespace covering the full device, delete all namespaces and create a single namespace that does
For zero-based cleanup:
Resolve the NVMe controller device from the PCI address
Unless the controller already presents exactly one namespace covering the full device, delete all namespaces and create a single namespace that does (so the entire storage is exposed for zeroing)
Write zeroes to the full device (
nvme write-zeroesif supported, otherwiseshred)
Both paths therefore leave a single namespace covering the full device, so the next tenant always receives a one-namespace controller. The driver reports success or failure to the agent, which records the outcome as described in Attachment Handle State Machine.
Attachment Handle State Machine¶
Cleanup state is tracked per attachment handle, not per device. An ARQ
records both a deployable and an attachment handle, which is redundant: a
deployable has many attachment handles but an attachment handle belongs to
exactly one deployable, so the attachment handle already identifies it. The
attachment handle is the unit handed to a guest, and therefore the unit
that becomes dirty and has to be cleaned before it is handed to the next
one. The attachment_state Enum on attach_handles carries that
lifecycle.
See Data model impact for its relationship to in_use and to
devices.status.
The states are available, allocated, pending_cleaning,
cleaning and error. An attachment handle is allocated while it
is bound to an ARQ and available when it is free and needs no cleaning.
pending_cleaning, cleaning and error are the states in which an
attachment handle still needs cleaning and must not be bound. Cleaning
states apply only to devices that support cleaning; the bind guard applies
to every device.
For an enabled NVMe controller with one attachment handle, the state
transitions and the resulting Placement accounting on its resource provider
(total=1) are shown below:
available (reserved=0)
│ bind: the Placement allocation records the usage;
│ reserved is unchanged
▼
allocated (reserved=0)
│ unbind: conductor records pending_cleaning, clears in_use
│ and recalculates reserved
▼
┌─> pending_cleaning (reserved=1)
│ │ agent receives clean_attachment_handles for the
│ │ selected handle, resolves its device, and records
│ │ cleaning on the handle through a state update on
│ │ the conductor
│ ▼
│ cleaning (reserved=1)
│ ├── cleanup succeeds ──> available (reserved=0)
│ └── cleanup fails ─────> error (reserved=1)
│ │
└─────────────────────────────────────┘
admin re-runs the failed cleanup
Placement inventory total is the number of attachment handles belonging
to the deployable represented by the resource provider. Placement subtracts
reserved from total to determine the inventory capacity available
for allocations. For an enabled device, the conductor calculates reserved
by counting the deployable’s attachment handles whose attachment_state
is pending_cleaning, cleaning or error. An attachment handle in
use is already accounted for by its Placement allocation, so bind leaves
reserved unchanged. For a disabled device (devices.status=maintaining),
reserved equals total in every state, including after successful
cleanup. The NVMe model in this cycle has one attachment handle per
controller, so total=1 and the enabled-device count is zero or one. A
multi-handle deployable can have several handles in the counted states at
the same time.
Enabling a device does not clear cleaning states, so the device enable path
recalculates reserved by the same rule instead of clearing it.
On instance deletion, the conductor checks device.supports_cleaning.
For non-NVMe devices it releases the attachment handle without dispatching
an RPC and records available on it. For an NVMe device it records
pending_cleaning on the attachment handle, recalculates reserved,
and casts clean_attachment_handles to the agent on the device’s host.
The agent RPC handler receives the clean_attachment_handles cast for
the selected attachment handle. It resolves the handle’s deployable, and
through it the device, from the resource tracker, which confirms in the
same step that the device is one this agent manages; a handle that does not
resolve is rejected. It then records attachment_state=cleaning on the
selected handle through a state update executed on the conductor using
object indirection. This object method only persists state; the
clean_attachment_handles agent RPC handler queues the hardware cleanup
in the bounded futurist pool. The attachment handle stays in cleaning
while waiting for a worker, with its reservation retained. When a worker is
available, the agent manager asks the resource tracker for the driver that
discovered the device and calls that driver’s cleanup(device), passing
the resolved Device object. The driver uses the device’s control path
ID and its locked-in cleanup action to invoke nvme-cli. The attachment
handle stays in cleaning, and so stays counted in reserved, while
waiting for a worker, being erased, or polling an already-running sanitize.
When the driver finishes, the agent records the outcome through a remotable
object method: mark_cleaned() on success, or a transition to error
on failure or timeout. The conductor validates the transition against the
persisted state and allocation ownership, writes the row, and recalculates
reserved by the rule above. If an operator disabled the device during
cleanup (status=maintaining), successful cleanup still records
attachment_state=available, but the recalculation yields
reserved=total because the device is disabled. A handle left in
error stays counted and cannot be reallocated.
The unbind path and the attachment-handle clean action dispatch cleanup through agent RPC; startup and periodic recovery enqueue the same workflow locally on the agent. The object query and state-update methods never invoke drivers or dispatch cleanup themselves.
Attachment handle state updates must be serialised per attachment handle so that only one operation mutates a handle at a time. The conductor validates each transition against the persisted state and allocation ownership and applies it as one serialised step, on every path that changes attachment handle state: bind, unbind, administrator retry, cleanup completion and recovery. The guarantee holds across API and conductor workers, which can run in separate processes on separate hosts, so a stale or duplicate request is rejected rather than allowed to overwrite a newer one.
On the agent, the same serialisation covers the whole cleanup workflow for an attachment handle, from the hardware commands through completion polling to reporting the result. A periodic recovery run and an API-driven dispatch must not race on the same handle, and a duplicate trigger for a handle already queued or running must not start a second cleanup, while cleanup of different handles proceeds concurrently within the worker pool limit. An NVMe controller carries exactly one attachment handle, so serialising per handle also serialises the hardware operations on the device behind it. The locking mechanism is an implementation choice; these guarantees are required.
An administrator can retry cleanup for a handle left in error through
the clean action described in REST API impact. The handle returns
to pending_cleaning, and from that point the agent follows exactly the
same workflow as an unbind-triggered cleanup.
For startup and periodic recovery of interrupted or missed cleanup, see Timeout and Crash Recovery.
Device Bind¶
Binding is gated by the attachment handles, not by an aggregate device
state. A bind is accepted when the device has at least one attachment
handle that is free (in_use is false) and in available. The
selector _do_allocate_attach_handle(), which filters on in_use=False
today, will gain the state condition. A multi-allocation device such as a
vGPU therefore keeps accepting binds while free attachment handles remain,
even though other attachment handles on the same device are already
allocated. A single-handle NVMe controller cannot accept another bind
while its attachment handle is in use. Attachment handles in
pending_cleaning, cleaning, or error are never candidates, so a
device with residual data is not rebound even though it has a free
attachment handle. These requirements apply to every device type.
Bind does not touch the Placement reservation: the allocation Placement
creates for the consumer already removes the capacity from what is
available. The reservation changes on unbind, when the released attachment
handle enters pending_cleaning, and again when cleanup finishes.
Timeout and Crash Recovery¶
NVMe cleanup operations can take minutes depending on drive size and sanitize method. The conductor-to-agent call is a cast, so the unbind path does not wait. The agent submits the operation to a worker and bounds its wait with the configurable timeout:
[nvme]
cleanup_timeout = 900 # seconds (default: 15 minutes)
If cleanup times out, the agent calls a remotable object method to request
error. The conductor records error on the attachment handle, which
keeps it counted in reserved. The agent requests available only
after it confirms that cleanup succeeded. If the agent cannot confirm the
state update, the attachment handle remains unavailable until
reconciliation succeeds.
Before discovery and reporting at startup, the agent reads the persisted
attachment-handle and allocation state for its host through remotable
object queries. The queries execute on the conductor and return versioned
object lists. The agent inspects the objects to identify attachment handles
in pending_cleaning or cleaning and attachment handles in
allocated without an active ARQ. Startup discovery establishes the
driver that owns each device before the agent executes recovered cleanup.
It preserves the selected cleanup action and attachment handle state; these
attachment handles remain unavailable.
The agent requests any required state transitions through separate
remotable object methods. The conductor checks current state and allocation
ownership before accepting each transition. An orphaned allocated
attachment handle first moves to pending_cleaning. A recovered pending
request moves to cleaning when the agent handles it, even if it must
wait for a worker. Interrupted work resumes in cleaning after the
conductor confirms the current state and allocation ownership. The agent
queues or resumes the cleanup locally through the owning driver. Both
cleaning states keep the attachment handle counted in reserved. If
sanitize is already running, the NVMe driver polls that operation instead
of starting another.
During each periodic resource update, the agent checks for missed cleanup
dispatches and unconfirmed final state updates. report_data() alone
does not read persisted state or request these transitions. Recovery uses
the same per-attachment-handle serialisation, selected cleanup action, and
reservation rules as normal cleanup. The conductor executes all database
queries and updates.
Alternatives¶
Relying on Nova PCI passthrough alone was rejected. Nova has a
one_time_use flag that sets reserved=total when a device is
allocated, but Nova never unreserves the device — it expects an external
entity to do so after cleanup. Nova PCI passthrough has no cleanup
mechanism for stateful devices like NVMe SSDs.
Using the Cyborg generic PCI driver with external cleanup automation
was rejected. The PCI driver only implements discover() with no
lifecycle management. There is no cleanup state field or cleanup()
method. External tooling has no way to coordinate with Cyborg’s
Placement reservations.
Data model impact¶
attach_handles.attachment_state
This driver uses the attachment_state Enum on attach_handles,
with values available, allocated, pending_cleaning,
cleaning and error. Moving the lifecycle state to attach_handles
requires a schema migration, a backfill and an AttachHandle version
bump to 1.1.
The backfill will set null handle states to allocated when in_use is
true and to available otherwise.
Device.supports_cleaning, which returns self.type == 'NVME', and
NVME in the type Enum are unaffected and stay as they landed in
2026.2.
Relationship to in_use and to devices.status
in_use says whether an attachment handle is held by an ARQ right now,
attachment_state says where that attachment handle is in the cleanup
lifecycle, and devices.status says whether an operator has disabled the
whole device. The conductor writes in_use and attachment_state in the
same update, so in_use=True always means attachment_state=allocated and
the cleaning states only occur with in_use=False. devices.status is
independent of both: a disabled device can hold attachment handles in any
state, and re-enabling it does not make a dirty attachment handle
schedulable.
Versioned object changes
The NVMe feature will add remotable query methods that return a host’s
attachment-handle and allocation state as versioned object lists.
Separate remotable methods validate and persist lifecycle transitions and
cleanup results, with mark_cleaned() recording successful completion.
Before changing state, those methods check persisted state and allocation
ownership on the conductor, reject stale updates and recalculate
Placement under this spec’s reservation rules. A repeated request must
not release a dirty attachment handle or one assigned to a new allocation.
These methods and any later change to their signatures require object
version bumps and updated expected fingerprints. New list objects start at
1.0 and record the supported versions of their members.
REST API impact¶
A new microversion is required for the attachment-handle resource. The
exact version number depends on merge ordering with other in-flight specs;
this spec claims the next available Cyborg microversion after its
dependencies land, currently expected to be 2.4. Adding NVME to the
type field does not require a microversion because the type field is
wtypes.text (free-form string) at the API layer.
The resource will be registered at the top level of the V2 API.
Operation |
Proposed request |
Successful response |
|---|---|---|
List |
|
|
Show |
|
|
Clean |
|
|
Each list item contains uuid, attachment_state and
deployable_uuid, which Cyborg resolves from the handle’s
deployable_id; the handle’s numeric ID and control path ID stay
internal. Show also returns attach_type, in_use and
attach_info, the JSON attachment data used by Nova, in the same format
as attach_handle_info in the ARQ API and with fields that depend on
attach_type. For a PCI attachment they identify the PCI domain, bus,
device slot and function:
{
"uuid": "c96f35bc-0dec-4db1-8392-8bc77e864761",
"attachment_state": "error",
"deployable_uuid": "03499325-0ace-4adf-861d-f3692d433806",
"attach_type": "PCI",
"attach_info": {
"domain": "0000",
"bus": "01",
"device": "00",
"function": "0"
},
"in_use": false
}
The next member of the list response is present when another page
exists:
{
"attach_handles": [
{
"uuid": "c96f35bc-0dec-4db1-8392-8bc77e864761",
"attachment_state": "error",
"deployable_uuid": "03499325-0ace-4adf-861d-f3692d433806"
}
],
"next": "/v2/attach_handles?marker=c96f35bc-0dec-4db1-8392-8bc77e864761"
}
List supports limit and marker. The default page size is 100 and
the maximum is 1000; a non-positive or out-of-range value is rejected with
400 Bad Request. The public marker is the last returned handle’s UUID.
Cyborg resolves the marker within the caller’s authorized scope regardless
of whether it matches the list filters. A malformed UUID or an unresolved
marker returns 400 Bad Request. Handles are returned in descending
created_at order, with id as the tie-breaker. The next link
preserves the caller’s filters and sets marker to the last handle in
the returned page.
attachment_state is an exact-match filter, so an operator can request
GET /v2/attach_handles?attachment_state=error. A device_uuid
exact-match filter is proposed for operators who need to start from a known
device. A handle whose state is still null because the backfill has not
initialized it is returned with attachment_state: null; the API never
reports such a handle as available solely because its state is unset.
Exact-match state filters do not match null rows, and the clean action
rejects them with 409 Conflict until the backfill initializes them.
Show validates the UUID and returns 404 Not Found for a well-formed UUID
with no matching handle. A malformed UUID returns 400 Bad Request. For
microversions below the feature microversion, these routes are not
available and return 404 Not Found; existing device and deployable
responses are unchanged in every microversion.
POST /v2/attach_handles/{uuid}/clean
This is an administrator-only action for retrying cleanup of a selected
handle. Cyborg resolves the owning device, verifies cleanup support, and
checks atomically that the handle is free and in error before moving
it to pending_cleaning. It returns 202 Accepted with an empty body
and dispatches the existing asynchronous cleanup workflow with that
handle.
Error response codes
400 Bad Request— the attachment handle belongs to a device that does not support cleaning.400 Bad Request— the configured agent RPC cap prevents the required version1.1cleanup call.403 Forbidden— the caller lacks the role required by thecyborg:attach_handle:cleanpolicy.404 Not Found— the attachment handle UUID does not exist.409 Conflict— the attachment handle is inavailablestate (already clean).409 Conflict— the attachment handle is inallocatedstate or is stillin_use.409 Conflict— the attachment handle is already inpending_cleaningorcleaningstate.409 Conflict— during the initial upgrade, the attachment handle’s state is still null because the backfill has not initialized it.
Policy for existing endpoints is unchanged. Reads are governed by separate
cyborg:attach_handle:get_all and cyborg:attach_handle:get_one
policies, both reusing the existing project-scoped
PROJECT_MANAGER_OR_ADMIN deployable inventory policy, so a project
manager or administrator can read handles within their project scope. The
clean action is governed by cyborg:attach_handle:clean, defaulting to
role:admin.
RPC API impact¶
A new RPC method will be added to the Cyborg agent, with a version bump
from 1.0 to 1.1:
def clean_attachment_handles(context, attach_handles):
"""Trigger async cleanup of released attachment handles.
:param context: request context
:param attach_handles: list of AttachHandle objects in
pending_cleaning; the retry action passes a list containing
only the selected handle
"""
clean_attachment_handles will supersede cleanup_device from [2].
The method is intentionally generic — it takes attachment handles rather
than NVMe-specific parameters, so any driver that implements cleanup()
can use the same RPC infrastructure. The attachment handle is the unit that
is cleaned, and it identifies everything the agent needs: its
deployable_id resolves to the deployable and therefore to the device
and the driver that discovered it. No Device object is passed, because
a handle that does not resolve to a device on the receiving host is not a
handle that host may clean.
The attachment handles must be passed rather than looked up on the agent.
ExtARQ.unbind() clears attach_handle_id and deployable_id on
the ARQ once it has deallocated the attachment handle, so the released
attachment handle is available to pass to the agent at unbind. For this
NVMe driver the list contains exactly one attachment handle.
The NVMe feature will reuse conductor RPC 1.1 from the indirection
spec [1] for its object methods, with corresponding object version bumps
and updated expected fingerprints.
The conductor’s unbind path and the API’s handle-targeted clean action both
write pending_cleaning on the selected handle locally and then cast
clean_attachment_handles to the agent, which runs the workflow
described in Attachment Handle State Machine. The cast returns
immediately, so Nova can finish instance deletion before cleanup completes.
Before dispatch, the conductor checks device.supports_cleaning, so a
released handle on a device without cleanup support never reaches this RPC.
For NVMe devices, the service that sends clean_attachment_handles checks
its own agent RPC client’s can_send_version('1.1') first. On the unbind
path that is the conductor: if the cap blocks the call, the conductor
records error on the attachment handle, which keeps it reserved. On the
clean path that is the API service, which returns 400 Bad Request when
the required RPC cannot be sent.
Object indirection does not let the conductor or API service invoke methods on the agent. Those calls use the agent RPC API. A blocked or unsupported call must not fall back to a dedicated completion RPC or direct database access from the agent.
Security impact¶
An attachment handle only returns to available after the erase
operation is confirmed complete. Failed or timed-out cleanups leave the
attachment handle in error, excluded from bind and counted in the
Placement reservation, so it is never reallocated with stale data.
Invoking nvme-cli to modify a device requires elevated permissions
(CAP_SYS_ADMIN). New privileged commands will reuse the existing
privsep context.
Verification of successful erasure is based on completed administrative commands and their reported status, not on assuming detach alone erases media. Cyborg trusts nvme-cli’s output for erasure confirmation; physical-level verification is the responsibility of nvme-cli and device firmware.
Long-running subprocesses are bounded by the cleanup_timeout
configuration. Concurrent cleanups per host are bounded by the futurist
thread pool size. Per-attachment-handle serialisation, described in
Attachment Handle State Machine, prevents concurrent cleanup attempts on
the same device.
Other end user impact¶
None
The OpenStack CLI will be extended with attach handle list,
attach handle show and attach handle clean. The OpenStack SDK
will gain an AttachHandle resource.
Performance Impact¶
Cleanup runs asynchronously after instance deletion. Attachment handles
stay reserved in Placement throughout the cleanup window, which can be up
to 15 minutes by default on large drives. Operators should monitor for
attachment handles accumulating in pending_cleaning, cleaning or
error.
The zero cleanup method (especially the shred fallback) on
large drives can take significantly longer than sanitize. Operators
using clear_action=zero on multi-terabyte drives should increase
cleanup_timeout accordingly.
Listing attachment handles will use a join to resolve their deployables’ public UUIDs.
Other deployer impact¶
Operators must install nvme-cli on compute nodes, set
[agent] enabled_drivers and [nvme] device_spec in
cyborg.conf, and tune cleanup_timeout for the largest drives in
the fleet.
Developer impact¶
The NVMe driver will use the existing GenericDriver.cleanup(device)
hook. A cleanup implementation must report success only after confirming
that hardware cleanup has completed.
The agent will invoke the hook and report the outcome. The conductor will
check the attachment handle’s current state and allocation ownership before
recording available if cleanup succeeded or error if cleanup failed
or timed out.
Upgrade impact¶
None
Enabling the generic NVMe driver is a post-upgrade configuration activity, not an in-place migration.As cyborg does not support rolling upgrade using the nvm driver required upgrade all host before enabling the new driver on any host.
Implementation¶
Assignee(s)¶
- Primary assignee:
chandankumar
- Other contributors:
None
Work Items¶
Phase 1 — Foundation:
Create the
NVMeDriverskeleton as a standalone driver.Add the schema migration, backfill and object version bump that move the lifecycle field to
attach_handlesasattachment_state.
Phase 2 — Driver functionality:
Validate
nvme-cliand the conductor indirection prerequisite ininit_host(), and add the remotable query methods returning a host’s attachment-handle and allocation state.Implement device discovery with
device_specmatching and NVMe capability detection, resolve the configured policy to a locked-in cleanup action, and report the capabilities to Placement as traits.
Phase 3 — Cleanup:
Add the
clean_attachment_handlesagent RPC with its version bump, and the remotable object methods that validate and persist cleanup transitions and results on the conductor.Compute the Placement reservation in the conductor from the attachment-handle states rather than hardcoding it, and call it from every path that changes an attachment handle state.
Implement cleanup coordination in the agent and hardware cleanup in
NVMeDriver.cleanup(), for both the sanitize and the zero path.Wire
ExtARQ.unbind()to recordpending_cleaningon the attachment handle it releases and to dispatch cleanup with it.
Phase 4 — Recovery:
Implement agent recovery of interrupted and missed cleanup, at startup and on periodic reconciliation.
Add the bind-path guard, so that only a free attachment handle in
availablecan be selected for a bind.
Phase 5 — REST API and microversion (last):
Add the V2 attachment-handle list, show and administrator-only clean endpoints and their policies in the new microversion.
Change the device enable path to recalculate the reservation instead of clearing it.
Add the openstacksdk resource and OpenStackClient commands, plus API sample tests, reference documentation and a release note for the attachment-handle resource.
Dependencies¶
nvme-cli is required only on hosts that enable the NVMe driver.
os-traits 3.9.0 or later is required to provide the standard traits.
The NVMe feature depends on the Versioned Object Indirection Support spec [1]. Its implementation must land before the feature uses remotable object methods.
Testing¶
Everything except the hardware erase itself can be simulated inside the
Cyborg tree, with nvme-cli faked at the driver boundary.
The Cyborg Tempest plugin and whitebox-tempest-plugin will be extended
to provide end-to-end integration coverage using pci-sim. A manual
test run on real NVMe hardware will be submitted before the feature
merges.
Documentation Impact¶
The Cyborg administrator documentation will add a page for enabling and
configuring the generic NVMe driver, including the nvme-cli requirement
on hosts that enable it. The page will include a short overview of the
cleanup policy and explain how to inspect and retry a failed cleanup.
Configuration option help will describe the cleanup policy options. The
page will also cover the deprecation of the Inspur and SSD drivers, with
examples of managing those devices through the generic driver.
The Cyborg Driver Development Guide will briefly describe driver support for cleanup and outline the cleanup state machine and workflow.
The accelerator API reference will describe the new microversion and the attachment-handle operations, their policies and API samples, with corresponding openstacksdk and OpenStackClient documentation. A release note will accompany the feature.
References¶
nvme-cli manual pages: https://github.com/linux-nvme/nvme-cli/tree/master/Documentation
History¶
Release Name |
Description |
|---|---|
2026.2 |
Accepted |
2027.1 |
Reproposed from 2026.2 with attachment-handle cleanup state and conductor updates via ovo indirection API. |