test/libvirt: clean up resources on DeleteVPC and resolve provisioner TODOs #3493
All Vouch review confidence checks passed
Residual risk 0.23 = Change Risk (0.43) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 369 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 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.354
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #3493"
general
weight: 0.35
stevenhorsman
Summary
Cleans up resource handling and a few leftover
TODOs in the libvirt E2E test provisioner. The whole change is in one file:src/cloud-api-adaptor/test/provisioner/libvirt/provision_common.go. Nothing outside the test provisioner is touched.What changed
1.
DeleteVPCnow removes the volumesCreateVPCmade (was a no-op returningnil)LibvirtProvisioner.createdVolumes.CreateVPCappends a volume to it only when it actually creates that volume; volumes that already existed are never recorded.DeleteVPCreturns immediately if the list is empty (no pool lookup), otherwise deletes the listed volumes from the storage pool.ERR_NO_STORAGE_VOL) counts as cleaned up. Any other lookup or delete failure is returned (joined witherrors.Join), and those volumes stay increatedVolumesso a later call can retry.DeleteVPCTODO.CreateVPCthenDeleteVPC). A separateprovisioner-cli -action=deprovisionrun builds a new provisioner and does not know what an earlier-action=provisioncreated. Persisting that across runs is left for a follow-up; the limitation is documented in theDeleteVPCdoc comment.2. libvirt handle leaks fixed in
CreateVPCandUploadPodvmNetwork,StoragePool,StorageVolandStreamhandles are now freed withFree()on every return path (previously several were never freed).UploadPodvmreads the image into memory once (previously re-read from disk for each volume) and uses its length for the upload, so the separateos.Statis gone.uploadToVolumehelper that frees the volume and stream withdeferand aborts the stream ifUploadorSendAllfails (previously the stream was left open on error).3. SSH key secret created with the Kubernetes client instead of
kubectlcreateSSHKeySecretno longer shells out tokubectl create secret; it builds thecorev1.Secretand applies it through the e2e-framework client. Removes theTODO rewrite this to use go's k8s frameworkand thekubectlruntime dependency for this step.upsertSecrethelper: creates the secret, or updates the data if it already exists. The old command failed on re-runs; this one is idempotent. The log message changes from "Created" to "Applied" accordingly.cfg.Client()is obtained once and reused for namespace creation too.4. Stale
TODOremoved inNewLibvirtProvisionernetworkandstoragedefault to"default"and are only overridden by non-empty properties, so they can never be empty. The// TODO: Check network and storage are not nil?is deleted; no extra validation was needed.Testing
gofmt,go build -tags libvirt ./test/...andgo vet -tags libvirtare clean.---
fixes: #3492
Assisted-by: IBM Bob