fix(ratelimiter): return error when olric setup fails#292
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe rate limiter now stops its caches when Olric or store initialization fails, returns a wrapped Olric error instead of continuing with a nil database, and updates comments describing tier behavior. ChangesRate limiter initialization
Estimated code review effort: 2 (Simple) | ~5 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/invocation-plane-services/ratelimiter/rate_limiter.go`:
- Line 304: Add a regression test for the Olric construction failure path in the
relevant rate-limiter startup function, verifying that an `olric.New` error
returns a nil limiter and propagates the same error. Use the repository’s native
test runner; if testing is infeasible, document the reason in the pull request
description.
- Around line 303-304: Remove the zap.L().Error call from the Olric
initialization failure path and continue returning err to the caller. Keep the
existing error propagation behavior in the surrounding initialization function
without adding duplicate logging.
- Around line 301-304: Update the Olric initialization error path after
olric.New in the rate-limiter setup to stop both ttlcache instances with
cache.Stop() and indexedPoliciesCache.Stop() before returning the error.
Preserve the existing error log and return values.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 865fa2c6-1ede-4bb7-9cf2-6ea71dda8474
📒 Files selected for processing (1)
src/invocation-plane-services/ratelimiter/rate_limiter.go
c1f1df9 to
8099447
Compare
8099447 to
4c15bfa
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/invocation-plane-services/ratelimiter/rate_limiter.go`:
- Around line 331-334: In the store initialization error path around NewStore,
call db.Shutdown(context.Background()) on a best-effort basis before returning
the store error, after stopping caches. Preserve the existing error logging and
ensure shutdown failures do not replace or suppress the original NewStore error.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 35fb9aae-c1e3-41bb-9839-594dee98dd38
📒 Files selected for processing (1)
src/invocation-plane-services/ratelimiter/rate_limiter.go
4c15bfa to
8c892dc
Compare
NewRateLimiter logged the olric.New error but continued with a nil db, so the following db.Start call panicked in a goroutine and crashed the process. Return the wrapped error instead of logging it, per the log-or-return rule, and stop the two ttlcache expiration goroutines on every constructor error path so failed setup does not leak them. Also replace three em dashes in nearby comments to satisfy the ASCII-only style rule. Closes NVIDIA#291 Signed-off-by: mesutoezdil <mesudozdil@gmail.com>
8c892dc to
8e138ae
Compare
TL;DR
NewRateLimiter logged the olric.New error and kept going with a nil db, so the next db.Start call panicked and crashed the process. Now it returns a wrapped error, and a stopCaches helper stops the two ttlcache goroutines on all three constructor error paths. go build and go test pass; no new test because olric.New cannot be forced to fail from outside the module.
Issues
Closes #291
Summary by CodeRabbit