HA: hardware-passthrough-aware failover (GPU/PCI devices) #7

Closed
CanuteTheGreat wants to merge 1 commit from feat/ha-passthrough-device-affinity into main

Mirrors the existing CPU-architecture-compatibility filter in ha/mod.rs for hardware passthrough (GPU/PCI). A VM with a passthrough device attached now only fails over to a node reporting an available, matching device (vendor_id:device_id); if none exists it cleanly goes to HaState::Error instead of silently migrating to an incompatible node.

  • PassthroughDeviceRequirement{vendor_id, device_id, device_name} in cluster/node.rs, matched by vendor:device ID (not PCI address, which is host-specific).
  • NodeResources.available_passthrough_devices / VmResources.required_passthrough_devices in cluster/balancer.rs, filtered before ClusterBalancer scoring.
  • HaResource/HaConfig.required_passthrough_devices in ha/mod.rs, checked on preferred_node and candidate nodes exactly like the architecture check.
  • 4 new tests mirroring the 3 existing architecture tests plus a composition test (arch-compatible but device-missing node still excluded).

Scoped to GPU-class PCI devices (reusing GpuManager discovery scope), not generalized to all PCI hostdev classes yet.

cargo check/test pass for horcrux-api + horcrux-common; all pre-existing ha tests unaffected. Not intended to merge yet -- opened for CI signal / review.

Mirrors the existing CPU-architecture-compatibility filter in ha/mod.rs for hardware passthrough (GPU/PCI). A VM with a passthrough device attached now only fails over to a node reporting an available, matching device (vendor_id:device_id); if none exists it cleanly goes to HaState::Error instead of silently migrating to an incompatible node. - PassthroughDeviceRequirement{vendor_id, device_id, device_name} in cluster/node.rs, matched by vendor:device ID (not PCI address, which is host-specific). - NodeResources.available_passthrough_devices / VmResources.required_passthrough_devices in cluster/balancer.rs, filtered before ClusterBalancer scoring. - HaResource/HaConfig.required_passthrough_devices in ha/mod.rs, checked on preferred_node and candidate nodes exactly like the architecture check. - 4 new tests mirroring the 3 existing architecture tests plus a composition test (arch-compatible but device-missing node still excluded). Scoped to GPU-class PCI devices (reusing GpuManager discovery scope), not generalized to all PCI hostdev classes yet. cargo check/test pass for horcrux-api + horcrux-common; all pre-existing ha tests unaffected. Not intended to merge yet -- opened for CI signal / review.
feat(ha): hardware-passthrough-aware failover for GPU/PCI devices
Some checks failed
CI / Check (pull_request) Failing after 51s
CI / Test (pull_request) Has been skipped
CI / Build Web UI (pull_request) Has been skipped
CI / Gentoo Docker Build (pull_request) Has been skipped
CI / Build (pull_request) Has been skipped
CI / Build-1 (pull_request) Has been skipped
CI / Security Audit (pull_request) Successful in 3m7s
f2ae9465b1
Mirrors the existing CPU-architecture-compatibility filter in
ha/mod.rs: HaResource/HaConfig (and NodeResources/VmResources in
cluster/balancer.rs) now carry required_passthrough_devices /
available_passthrough_devices, keyed by vendor_id:device_id (NOT
PCI address, since bus/slot layout differs host to host -- the same
logical GPU model needs to match across different physical PCI
addresses on the failover target).

- cluster/node.rs: new PassthroughDeviceRequirement{vendor_id,
  device_id, device_name} + passthrough_devices_satisfied() helper
  (multiset match: a VM needing 2x of the same model needs 2 distinct
  available units).
- cluster/balancer.rs: NodeResources gains
  available_passthrough_devices (live, not-in_use snapshot);
  VmResources gains required_passthrough_devices.
  ClusterBalancer::find_best_node filters candidates on this
  immediately after the existing architecture filter, before scoring.
- ha/mod.rs: HaResource/HaConfig gain required_passthrough_devices
  (#[serde(default)] for backward compat). find_best_node_for_migration
  applies the same device-availability check to preferred_node and to
  the known-resource candidate set, reusing the existing 'no suitable
  node' -> HaState::Error path when nothing qualifies.
- 4 new tests mirroring the 3 existing architecture tests:
  migrates-to-matching-gpu-node, never-migrates-to-node-with-gpu-
  already-in_use, errors-when-no-matching-gpu-available, and a mixed
  composition test proving an arch-compatible-but-device-missing node
  is still excluded (and vice versa).
- Updated all existing HaConfig/NodeResources/VmResources literals
  (ha/mod.rs tests, cluster_tests.rs, main.rs add_ha_resource) for the
  new fields.

All pre-existing ha::tests pass unchanged, including
test_failover_x86_vm_never_migrates_to_riscv_node,
test_failover_riscv_vm_only_migrates_to_riscv_node, and
test_failover_riscv_vm_errors_when_no_riscv_node_available.

Scope: GPU-class PCI devices only (reusing GpuManager's discovery
scope), not generalized to all PCI hostdev classes -- GPU passthrough
is the dominant real-world case here; a generic PCI-hostdev
inventory can reuse the same PassthroughDeviceRequirement type later
if needed.

Not merged -- left for review.
Author
Owner

Closing: this PR's exact content (same commit message "feat(ha): hardware-passthrough-aware failover for GPU/PCI devices") was already landed directly on main at c53a788 on 2026-10-04, per the repo's "push directly to main, no PRs" policy -- the cluster/node.rs PassthroughDeviceRequirement/passthrough_devices_satisfied helper, the balancer.rs available/required_passthrough_devices fields, and the ha/mod.rs HaResource/HaConfig wiring are all present on main today (verified via git show origin/main:horcrux-api/src/ha/mod.rs/cluster/balancer.rs/cluster/node.rs). Test-merging this branch into current main (resolving the one trivial import-formatting conflict in ha/mod.rs) produces a byte-for-byte empty diff against main -- there is nothing left for this PR to contribute. Closing as redundant rather than leaving a permanently-unmergeable stale PR open against issue #7 (which is itself resolved by c53a788).

Closing: this PR's exact content (same commit message "feat(ha): hardware-passthrough-aware failover for GPU/PCI devices") was already landed directly on `main` at c53a788 on 2026-10-04, per the repo's "push directly to main, no PRs" policy -- the `cluster/node.rs` PassthroughDeviceRequirement/passthrough_devices_satisfied helper, the balancer.rs available/required_passthrough_devices fields, and the ha/mod.rs HaResource/HaConfig wiring are all present on main today (verified via `git show origin/main:horcrux-api/src/ha/mod.rs`/`cluster/balancer.rs`/`cluster/node.rs`). Test-merging this branch into current main (resolving the one trivial import-formatting conflict in ha/mod.rs) produces a byte-for-byte empty diff against main -- there is nothing left for this PR to contribute. Closing as redundant rather than leaving a permanently-unmergeable stale PR open against issue #7 (which is itself resolved by c53a788).
CanuteTheGreat closed this pull request 2026-10-06 15:53:07 -07:00
Some checks failed
CI / Check (pull_request) Failing after 51s
CI / Test (pull_request) Has been skipped
CI / Build Web UI (pull_request) Has been skipped
CI / Gentoo Docker Build (pull_request) Has been skipped
CI / Build (pull_request) Has been skipped
CI / Build-1 (pull_request) Has been skipped
CI / Security Audit (pull_request) Successful in 3m7s

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
CanuteTheGreat/horcrux!7
No description provided.