Repository navigation
evetest: recover from transient Proxmox failures in the broker - #7195
milan-zededa wants to merge 4 commits into
Conversation
dd4cba8 to
b85cb71
Compare
|
Claude finished @milan-zededa's task in 4m 13s —— View job Review completeI reviewed all three changed files against Overall: solid, carefully reasoned change. Lock ordering is consistent ( One point raised inline ( No correctness, security, or concurrency bugs found beyond that note. Checklist
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7195 +/- ##
==========================================
+ Coverage 31.01% 31.45% +0.44%
==========================================
Files 562 573 +11
Lines 101231 102826 +1595
==========================================
+ Hits 31399 32349 +950
- Misses 67389 68083 +694
+ Partials 2443 2394 -49 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
a1fff8f to
6f6c40a
Compare
|
@claude Do a fresh new PR review. |
|
Claude finished @milan-zededa's task in 3m 39s —— View job Fresh review — PR #7195Re-reviewed all four changed files from scratch, focusing on the five fixes and their concurrency. Overall: this holds up well. The reasoning in the doc comments is unusually careful and matches the code. Spot checks that passed:
Two non-blocking notes posted inline:
No correctness, security, or concurrency bugs found. Test coverage for each fix is thorough. · branch |
2d4e9d1 to
a131e95
Compare
When TeardownDevice fails, the Proxmox provider keeps the device in its devices map so that the teardown can be retried. The broker, however, forgets the device, and as a client session reuses its SDN device name, every later SetupDevice of the session failed with "device already exists". This happened in a nightly run where PVE completed the delete of the SDN VM two seconds after the broker's teardown timed out: the VM was gone, yet all remaining tests of the suite failed on its stale entry. Mark the device whose teardown failed, and let SetupDevice finish that teardown and continue the setup. A device that was never torn down is still rejected with "device already exists", so that a broker bug which sets up a live device again fails the test instead of destroying the device's VM. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Milan Lenco <milan@zededa.com>
retryProxmoxCall ran every attempt on the caller's context. When the first attempt hung until the deadline, the retries it announced never ran. In a nightly run the broker's one-minute teardown of an SDN VM timed out this way while PVE was still deleting the VM, which it completed two seconds later, and the failed teardown then broke the rest of the test suite. Give each attempt its own context, bounded to an equal share of the time left until the caller's deadline, minus the pauses before the remaining attempts. An attempt that fails early leaves its time to the next ones, and the last attempt gets all the time left. When the time left would give an attempt less than 30 seconds, plan fewer attempts instead: an attempt cut that short is unlikely to succeed, and may still leave behind what its call started. Calls without a deadline are unaffected. Raise the per-device teardown budget from one to three minutes, so that the first delete attempt gets about a minute. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Milan Lenco <milan@zededa.com>
A VM create fails transiently on a loaded PVE host, and SetupDevice then
failed the device setup, although a setup on the same host seconds later
went through. Both the create call and the create task that PVE runs
afterwards were seen failing in nightly runs:
- PVE could not start the worker for the create ("got no worker upid -
start worker failed").
- On a host with a ZFS pool on a single SATA SSD, creates timed out on
the storage lock, which PVE holds for the whole import of a disk,
while several VMs were created at once:
unable to create VM 106 - cannot import from
'local:import/ev-eve-0bee873a-edge-dev-0.qcow2' - can't lock file
'/var/lock/pve-manager/pve-storage-farfalle-pve-zfs-pool' - got timeout
Move the VMID allocation, the create and the wait for its task into
createAndWaitVM and retry it, with a fresh VMID on each attempt, after
removing whatever the failed attempt left behind. A failed create task
is a runtime problem on the host, as PVE rejects invalid options already
in the create call, and is retried. An error from buildVMOptions is not
retried, and neither is a failure of the wait itself (e.g. it timed out
client-side), as PVE may still be creating the VM. The API calls of an
attempt are bounded by its share of the deadline, while the wait and the
cleanup run on the deadline of the whole device setup: the import can
take a while, and the cleanup must not run on the context that just
expired. As the VM of a failed create is now always removed right where
the create failed, SetupDevice no longer has to track whether a VM was
created.
The removal runs without the VMID lock, which the create holds only
while it allocates the VMID and creates the VM: the import, the wait and
the retries of the removal could otherwise block all other creates for
minutes. A VMID that is no longer locked can be allocated again, though,
and PVE removes the VM of a failed create task itself, so a removal by
VMID could hit the VM of another device. Every VMID is recorded in its
device before its VM is created, so stop and delete a VM by its VMID, in
teardown and in the startup sweep too, only after checking under the
VMID lock that no other device holds the VMID. Only the lookup, the check
and the call that starts the task run under the lock; the wait for the
task does not, as the VM, and so its VMID, exists until the task
completes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Milan Lenco <milan@zededa.com>
The Proxmox provider removes the VMs, VNets and import volumes that no device owns only when the broker starts. A VM whose failed create could not be removed, for example, stayed on the host until the next broker run, which with auto-upgrade may be days away. So did a device whose teardown failed for good once its session ended, as only a setup of the same name would finish that teardown. Run the startup sweep every 30 minutes too, and make it spare what the devices own, set up or being set up: - It first finishes the failed teardowns, reserving each name while doing so, so that a concurrent setup of it fails instead of destroying the same VM. - It lists the VMs while holding the VMID lock, which every create holds while it allocates the VMID, records it in its pending device and creates the VM, and spares the VMIDs of all devices. A VM missing from those is owned by no device and never will be, as the VMID of an existing VM is never allocated again. The listing is bounded so that a hung call cannot block creates for long. Each orphan is then removed only if no device holds its VMID by then. - It removes only the xconnect VNets the provider does not track, holding sdnMutex, under which the VNets are created and tracked. The tracked ones that no device uses are garbage-collected as after a teardown. - It spares the import volumes of the devices set up or being set up. The volume names now start with the number of the setup, unique to each device, which a setup records in its pending device before it uploads anything. This tells the volumes of each device apart exactly, even when one device name is a prefix of another, and a setup never uploads a volume of the same name as one the sweep is removing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Milan Lenco <milan@zededa.com>
a131e95 to
fb49c8b
Compare
|
@claude Do a fresh new PR review. |
|
Claude finished @milan-zededa's task in 2m 19s —— View job Fresh review — PR #7195Re-read all four changed files from scratch (diff against Verdict: this holds up. The doc comments are unusually precise and match the code, and every point raised in the two earlier rounds was addressed (the Checks that passed on this read:
No inline comments to add — the two non-blocking notes from the last round were both fixed. Nothing blocking.
|
Description
Make the Proxmox provider of the evetest broker recover from transient
Proxmox failures that made whole test suites fail in the nightly runs. One
commit per problem:
TeardownDevicefails, the provider keeps the device in its map so thatthe teardown can be retried, but the broker forgets it. A client session
reuses its SDN device name, so every later test of the suite failed with
device "sdn-<client>" already exists, even when PVE had deleted the VMseconds after the teardown gave up. A device whose teardown failed is now
marked, and
SetupDevicefinishes its teardown first. A device that wasnever torn down is still rejected, so that a broker bug which sets up a
live device again fails instead of destroying its VM. Seen e.g. in the 16.0-stable nightly
45103341150,
where 8 tests of
TestDeviceConnectivitySuitein a row failed this way.retryProxmoxCallran all attempts on the caller's context, so a firstattempt that hung until the deadline left no time for the retries it
announced (
Attempt 1/3: ... (will retry)was never followed by asecond attempt). Each attempt now gets an equal share of the time left,
and fewer attempts are made when that share would drop below 30 seconds.
The per-device teardown budget is raised from one to three minutes,
as deleting a VM on a loaded host was seen to take just over a minute.
This is what left the devices behind in (1).
host, failing the test, while the next setup seconds later went through.
Both the create call (
500 got no worker upid - start worker failed,500 user name not set, e.g. in the master nightly45075176035,
TestKubeRegistrationSuite) and the create task that PVE runs afterwardsfailed: in the 17.0-stable nightly
45092013678
(
TestStorageSuite,TestUpgradeSuite) creates timed out on the storagelock, which PVE holds for the whole import of a disk:
cannot import from 'local:import/...' - can't lock file '/var/lock/pve-manager/pve-storage-<id>' - got timeout.The VMID allocation, the create and the wait for its task are now
retried, with a fresh VMID, after the failed VM is removed. A failure of
the wait itself, e.g. a client-side timeout, is not retried, as PVE may
still be creating the VM.
The removal of a failed VM does not run under the VMID lock, which would
block all other creates meanwhile. As a VMID that is not locked can be
allocated again (and PVE removes the VM of a failed create task itself),
a VM is stopped or deleted by its VMID, also in teardown and in the
sweep, only after checking under the VMID lock that no other device holds
that VMID. Only issuing the call runs under the lock, not the wait for
its task.
volumes that no device owns, e.g. a VM whose failed create could not be
removed, were only removed when the broker started, which with
auto-upgrade may be days later. So was a device whose teardown failed for
good once its session ended. The startup sweep now also runs every 30
minutes, and spares what devices own, set up or being set up:
while it allocates the VMID and records it in its pending device;
mutex under which VNets are created and tracked;
start with the number of the setup, unique to each device, so the
sweep tells the volumes of each device apart exactly, and a setup
never uploads a volume with the name of one the sweep is removing.
How to test and validate this PR
evetest/broker/providercover each change with a fake PVEAPI: a leftover device whose VM is gone is cleared, and kept when its VM
cannot be removed; a device that was never torn down is not removed by a
setup of its name; a failed create call is retried with a new VMID; the
deadline is split among the attempts, and a timed-out attempt is retried;
a create task that PVE completed as failed is retried, and a failed wait
for it is not; a VM whose VMID another device holds is never removed; the orphan sweep finishes the failed teardowns and removes
only the VMs, VNets and import volumes that no device owns.
make -C evetestchecks and the nightly evetest runs: the failuresignatures listed above should no longer fail suites.
Changelog notes
None (evetest only).
PR Backports
Checklist
check them: this changes only the evetest broker, which is covered by unit
tests; it was not run against a real Proxmox host yet.