fix: start API server only after cache sync to prevent startup race#836
fix: start API server only after cache sync to prevent startup race#836mblos wants to merge 2 commits into
Conversation
|
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe manager startup flow now gates HTTP API server startup by waiting for controller-runtime cache synchronization. If cache sync fails, the process exits, and the manager is started with the same signal context so API server, cache sync, and manager share shutdown signaling. ChangesManager Cache Synchronization Gate
Estimated code review effort🎯 2 (Simple) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
cmd/manager/main.go (1)
913-913: 💤 Low valueError message could mention process termination.
The message "not starting api server" is accurate but understates the action—the process exits entirely on line 914. For operators debugging startup failures, mentioning the exit would be clearer.
📝 Optional improvement
- setupLog.Error(nil, "cache sync failed, not starting api server") + setupLog.Error(nil, "cache sync failed, exiting before starting api server")🤖 Prompt for 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. In `@cmd/manager/main.go` at line 913, Update the log message emitted by the setupLog.Error call in cmd/manager/main.go so it explicitly states the process will exit; change the message from "cache sync failed, not starting api server" to something like "cache sync failed, exiting process; not starting API server" so operators know the process terminates after this failure (adjust the setupLog.Error invocation accordingly).
🤖 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 `@cmd/manager/main.go`:
- Around line 912-915: Replace the non-cancellable context used in main() with a
signal-aware cancellable context and reuse it for cache sync and manager
startup: create ctx via ctrl.SetupSignalHandler() at the start of main()
(instead of context.Background()), pass that ctx into
mgr.GetCache().WaitForCacheSync(ctx) and into mgr.Start(ctx) so cache sync and
the API server respect SIGTERM/SIGINT and cancel promptly; update any other uses
of the original ctx variable in main() to the new signal-aware ctx (references:
main(), mgr.GetCache().WaitForCacheSync, mgr.Start, ctrl.SetupSignalHandler).
---
Nitpick comments:
In `@cmd/manager/main.go`:
- Line 913: Update the log message emitted by the setupLog.Error call in
cmd/manager/main.go so it explicitly states the process will exit; change the
message from "cache sync failed, not starting api server" to something like
"cache sync failed, exiting process; not starting API server" so operators know
the process terminates after this failure (adjust the setupLog.Error invocation
accordingly).
🪄 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: Pro
Run ID: 5383e91f-ab84-4c9b-b967-399edf038191
📒 Files selected for processing (1)
cmd/manager/main.go
Test Coverage ReportTest Coverage 📊: 69.1% |
No description provided.