fix(supervisor): address audit findings (switch-none rollback, dedup, cleanup)#386
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
Warning Review limit reached
More reviews will be available in 17 minutes and 30 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthrough
ChangesMonotonic time sourcing, error handling refactor, and transactional SWITCH none
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
f2a7613 to
02a378a
Compare
… cleanup) - handleSwitchNone: make global switch-to-none transactional like handleSwitch. Previously an early return on mid-loop restart failure left already-processed devices with cleared mappers and no thread (inconsistent, daemon-restart only to recover). Now build a SwitchTx per target, commit each, and roll back every already-committed device on any restart failure. Adds commitSwitchToNone and two regression tests (rollback-on-failure + clear-on-success). - finalizeRebind: replace manual catch-and-free blocks with errdefer for dev_copy/phys_copy and a plain devname_map.remove on the rollback path, matching attachWithInstanceResult's style; no behavior change. - nowNs: delegate to event_loop.monotonicNs instead of re-implementing clock_gettime(CLOCK_MONOTONIC); test override path unchanged. - handleStatus: drop the PR-ε.1 tracking label from the wedge-instrumentation comment, keeping the explanatory text. refs: codebase audit
02a378a to
4f1487e
Compare
Addresses 4 of 6 audit findings in src/supervisor.zig (2 skipped as out-of-scope refactors, see below).
Changes
handleSwitch: build aSwitchTxper target, commit each via newcommitSwitchToNone, androllbackCommittedSwitchesrestores every already-committed device on any restart failure. Oldswitch_mappingownership moves into the tx and is freed bycleanupSwitchTxs(same as the named-mapping path).dev_copy/phys_copywitherrdefer, and the rollback errdefer with a plaindevname_map.remove(the errdefers own the frees, no double-free). MatchesattachWithInstanceResultstyle; no behavior change.event_loop.monotonicNs()instead of re-implementingclock_gettime(CLOCK_MONOTONIC). Test override path unchanged. No circular import (monotonicNsis a free function; event_loop does not import supervisor).Skipped (out-of-scope refactors)
Test plan
global SWITCH none rolls back all devices on failure(injects commit failure at idx 1, asserts device 0 mapper restored not null + device 1 restored) andglobal SWITCH none clears all mappers on success../scripts/padctl-docker test→ EXIT=0 (full suite, testing.allocator leak-checked).zig fmt --check src/supervisor.zig(zig 0.15.2) → clean.refs: codebase audit
Summary by CodeRabbit