fix: revert to per-resource watcher + increase FD limit at startup#238
Merged
Conversation
The shared watcher approach has fundamental issues: - Each fileREST instance starts a goroutine reading from the same Events channel - This causes event distribution conflicts between resources - Multiple resources adding the same directory causes issues Solution: 1. Revert to each resource having its own watcher 2. Increase file descriptor limit to 65535 in main.go init() 3. Add better error messages when watcher creation fails This ensures proper event isolation while providing enough FD headroom.
|
CodeReview流程已终止 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
PR #236's shared watcher approach causes runtime failure:
Root Cause Analysis
The shared watcher design has fundamental architectural flaws:
Event channel conflict: Each fileREST instance starts a goroutine reading from the same
watcher.EventschannelDirectory watch conflicts: Each resource calls
dirWatcher.Add(objRootPath)on different subdirectoriesStill hits FD limit: Even with shared watcher, other initialization steps may consume FDs before watcher creation
Solution
Revert to per-resource watcher (simpler & correct) + increase system FD limit early:
Changes
main.go: Add
init()to increase FD limit to 65535 before any initializationfile_rest.go: Restore per-resource watcher creation
Destroy()apiserver.go: Remove shared watcher logic
Why This Works
Testing
Alternative Considered
A truly shared watcher would require:
This adds significant complexity for minimal benefit given FD limits are easily increased.
Supersedes #236 and #237