fix: name the VM a failed create_vm_from_cloud_init leaves behind (#28) #41

Merged
christianmanivong merged 3 commits from fix/half-built-vm-28 into main 2026-11-01 23:57:55 +00:00
Owner

Once qemu.post has created the VM shell, any later failure in create_vm_from_cloud_init (disk import/storage, NIC config, snippet storage, cloud-init config, start) raises VMProvisionIncomplete(…, vmid=…, node=…) from napalm-device-types, with the original error as its cause. Failures before a VM exists raise as before. The driver does not clean up itself — netOrk's rollback removes the VM and audits it.

Behaviour change: ValueErrors raised after the shell exists now arrive as the __cause__ of VMProvisionIncomplete (a RuntimeError, as the contract already states).

The NIC config building moved into a pure helper _nic_config_args(); the ratchet baseline shrinks (complexity 25→18, lines 232→220).

Depends on napalm-device-types feat/vm-create-partial-failure (VMProvisionIncomplete). The device-types floor must be raised to the release containing it (4.23.0) before this merges, or the lowest CI job fails.

Tested: fixtures only, tests/test_vm_half_built.py (three failed first). pytest 392 passed, ruff, mypy, napalm-standard check/ratchet green.

Closes #28

Once `qemu.post` has created the VM shell, any later failure in `create_vm_from_cloud_init` (disk import/storage, NIC config, snippet storage, cloud-init config, start) raises `VMProvisionIncomplete(…, vmid=…, node=…)` from napalm-device-types, with the original error as its cause. Failures before a VM exists raise as before. The driver does not clean up itself — netOrk's rollback removes the VM and audits it. Behaviour change: `ValueError`s raised after the shell exists now arrive as the `__cause__` of `VMProvisionIncomplete` (a `RuntimeError`, as the contract already states). The NIC config building moved into a pure helper `_nic_config_args()`; the ratchet baseline shrinks (complexity 25→18, lines 232→220). **Depends on** napalm-device-types `feat/vm-create-partial-failure` (VMProvisionIncomplete). The device-types floor must be raised to the release containing it (4.23.0) before this merges, or the `lowest` CI job fails. Tested: fixtures only, `tests/test_vm_half_built.py` (three failed first). pytest 392 passed, ruff, mypy, `napalm-standard check`/`ratchet` green. Closes #28
christianmanivong added 1 commit 2026-11-01 21:15:01 +00:00
fix: name the VM a failed create_vm_from_cloud_init leaves behind
driver / standard (pull_request) Successful in 19s
driver / lint (pull_request) Successful in 15s
driver / types (pull_request) Successful in 1m5s
driver / test (3.12) (pull_request) Failing after 1m6s
driver / lowest (pull_request) Failing after 5s
driver / test (3.13) (pull_request) Failing after 58s
driver / build (pull_request) Successful in 31s
driver / security (pull_request) Successful in 1m9s
CI / driver (pull_request) Failing after 2m49s
driver / publish (pull_request) Skipped
61821cd607
A failure after the VM shell existed (disk import, NIC or snippet config,
start) raised without the VMID, so the caller could not remove the
half-built VM and it stayed on the node. It now raises napalm-device-types'
VMProvisionIncomplete with vmid and node, the failure as its cause. A
failure before the shell exists raises as before.

The NIC config strings are built by a helper of their own, which keeps
create_vm_from_cloud_init within its quality baseline.

Closes #28
christianmanivong added 2 commits 2026-11-01 23:54:55 +00:00
# Conflicts:
#	CHANGELOG.md
#	tests/quality_baseline.json
chore(deps): floor napalm-device-types at 4.23.0
driver / standard (pull_request) Successful in 21s
driver / lint (pull_request) Successful in 24s
driver / types (pull_request) Successful in 1m12s
driver / test (3.13) (pull_request) Successful in 1m9s
driver / test (3.12) (pull_request) Successful in 1m21s
driver / lowest (pull_request) Successful in 43s
driver / build (pull_request) Successful in 32s
driver / security (pull_request) Successful in 1m14s
CI / driver (pull_request) Successful in 2m47s
driver / publish (pull_request) Skipped
3233ee24a0
4.23.0 is on PyPI with everything this branch uses; the git pre-install
in CI is no longer needed.
christianmanivong merged commit 6a8132e234 into main 2026-11-01 23:57:55 +00:00
christianmanivong deleted branch fix/half-built-vm-28 2026-11-01 23:57:55 +00:00
Sign in to join this conversation.