libvirt: fix volume cleanup and UUID capture on domain start failure #3357
All Vouch review confidence checks passed
Residual risk 0.15 = Change Risk (0.39) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.39 · 261 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.333
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #3357"
general
weight: 0.35
mkulke
What this PR does
Fixes two bugs in
CreateDomaininsrc/cloud-providers/libvirt/libvirt.go.1. Volumes leaked on domain start / IP-wait failure
Root and ISO volumes were uploaded to the storage pool before the domain was defined, but no cleanup ran if
Create()failed or the subsequent IP-wait timed out. Stale volumes accumulated on every retry, particularly visible when using a corrupted backing image (related: #1737).Deferred cleanup guards are added for both volumes and are disarmed only once the domain is started and ownership of cleanup is transferred to
DeleteDomain. This avoids double-deletion sinceDeleteDomainalready removes the domain and its associated volumes viagetDeletableDiskPaths.2. UUID captured after
Create()The domain UUID was retrieved after
Create()was called. IfCreate()failed, the function returnednilwith noinstanceID, leaving the caller unable to invokeDeleteDomainfor cleanup. UUID is now captured immediately afterDefineXMLreturns (beforeCreate()), so a non-nil result with a validinstanceIDis always returned on error.Testing
Unit tests
TestCreateDomainBootFailureReturnsInstanceForCleanup: uploads a deliberately corrupt backing image, callsCreateDomain, asserts a non-nil result with a populatedinstanceIDis returned on boot failure, and verifiesDeleteDomainfully removes the domain and its volumes — covering the cleanup path end to end.Integration tests (live libvirt)
TestCreateDomainXMLArchitectures,TestGetDeletableDiskPaths, andTestGetGuestForArchType.End-to-end