refactor: Migrate instance handler to WithTx#476
Conversation
Applies the `WithTx` pattern from NVIDIA#462 to 4 sites in instance.go: `Create`, `handleReboot`, `Update`, and `Delete`. This required a few mechanical adjustments: - Workflow execution + timeout handling moved inside each closure; inner errors renamed to `"wferr"` so they don't shadow the outer `"err"`. - Result variables (`instance`, `ifcs`, `ui`, `newdbIfcs`, ...) are now declared outside the closures and assigned inside, since the response builders need them after the tx commits (but this is to be expected). - `buildInstanceUpdateRequestOsConfig` used to write the HTTP response directly via `c.JSON(...)` inside the `tx`. The helper now returns a `*cutil.APIError` that flows through `HandleTxError` like everything else. Keeping these PRs smaller and tightly scoped so they're: - In theory a little easier to read. - More tightly scoped / less "blast radius" per PR. - A little nicer on/for @coderabbitai. 😆 I do wish the diffs were easier to read, but it is what it is! Signed-off-by: Chet Nichols III <chetn@nvidia.com>
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes. 💤 Files selected but had no reviewable changes (1)
⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Review rate limit: 9/10 reviews remaining, refill in 6 minutes. Comment |
🔐 TruffleHog Secret Scan✅ No secrets or credentials found! Your code has been scanned for 700+ types of secrets and credentials. All clear! 🎉 🕐 Last updated: 2026-05-04 15:55:29 UTC | Commit: 2755e99 |
🔍 Container Scan Summary
Per-CVE detail lives in the per-service |
Description
Applies the
WithTxpattern from #462 to 4 sites in instance.go:Create,handleReboot,Update, andDelete.This required a few mechanical adjustments:
"wferr"so they don't shadow the outer"err".instance,ifcs,ui,newdbIfcs, ...) are now declared outside the closures and assigned inside, since the response builders need them after the tx commits (but this is to be expected).buildInstanceUpdateRequestOsConfigused to write the HTTP response directly viac.JSON(...)inside thetx. The helper now returns a*cutil.APIErrorthat flows throughHandleTxErrorlike everything else.Keeping these PRs smaller and tightly scoped so they're:
I do wish the diffs were easier to read, but it is what it is!
Signed-off-by: Chet Nichols III chetn@nvidia.com
Type of Change
Services Affected
Related Issues (Optional)
Breaking Changes
Testing
Additional Notes