-
Notifications
You must be signed in to change notification settings - Fork 32
fix: node drainer enqueuing duplicate elements [WIP] #644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Ajay Mishra <[email protected]>
π WalkthroughWalkthroughThe Changes
Estimated code review effortπ― 2 (Simple) | β±οΈ ~12 minutes Pre-merge checks and finishing touchesβ Passed checks (3 passed)
β¨ 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
π§Ή Nitpick comments (1)
node-drainer/pkg/reconciler/reconciler.go (1)
231-242: Excellent fix for duplicate enqueues!The conditional enqueue based on
ModifiedCount > 0correctly prevents duplicate enqueues during change stream replays or cold starts. The atomic MongoDB update with the$ne: StatusInProgressfilter ensures only one thread can claim an event, and only that thread will enqueue it.Optional: Improve log message accuracy
The debug log message at line 238 says "Event already in progress" but this case also occurs when
MatchedCount = 0(document not found). Consider making the message more precise:- slog.Debug("Event already in progress, skipping enqueue", + slog.Debug("Skipping enqueue - event not claimed", "node", nodeName, - "documentID", fmt.Sprintf("%v", documentID)) + "documentID", fmt.Sprintf("%v", documentID), + "modifiedCount", result.ModifiedCount, + "matchedCount", result.MatchedCount)This provides clearer context when debugging, distinguishing between "already in progress" vs. "document not found" cases.
π Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
π Files selected for processing (1)
node-drainer/pkg/reconciler/reconciler.go
π§° Additional context used
π Path-based instructions (1)
**/*.go
π CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.go: Follow standard Go conventions with gofmt and golint
Use structured logging vialog/slogin Go code
Wrap errors with context usingfmt.Errorf("context: %w", err)in Go code
Withinretry.RetryOnConflictblocks, return errors without wrapping to preserve retry behavior
Use meaningful variable names such assyncedoverokfor cache sync checks
Useclient-gofor Kubernetes API interactions in Go code
Prefer informers over direct API calls for watching Kubernetes resources
Implement proper shutdown handling with context cancellation in Go code
Package-level godoc required for all Go packages
Function comments required for all exported Go functions
Use inline comments for complex logic only in Go code
TODO comments should reference issues in Go code
Extract informer event handler setup into helper methods
Use separate informers for different Kubernetes resource types
Files:
node-drainer/pkg/reconciler/reconciler.go
β° Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
- GitHub Check: modules-lint-test (labeler)
- GitHub Check: modules-lint-test (janitor)
- GitHub Check: modules-lint-test (node-drainer)
- GitHub Check: modules-lint-test (fault-quarantine)
- GitHub Check: modules-lint-test (platform-connectors)
- GitHub Check: E2E Tests (AMD64 + PostgreSQL)
- GitHub Check: E2E Tests (AMD64 + MongoDB)
- GitHub Check: E2E Tests (ARM64 + MongoDB)
- GitHub Check: E2E Tests (ARM64 + PostgreSQL)
- GitHub Check: CodeQL PR Analysis
Summary
Not working
Type of Change
Component(s) Affected
Testing
Checklist
Summary by CodeRabbit
βοΈ Tip: You can customize this high-level summary in your review settings.