fix(flagd-proxy): guard cleanup against a multiplexer whose watcher has not started - #4
Open
arena-ai-coding-agent[bot] wants to merge 1 commit into
Open
fix(flagd-proxy): guard cleanup against a multiplexer whose watcher has not started#4arena-ai-coding-agent[bot] wants to merge 1 commit into
arena-ai-coding-agent[bot] wants to merge 1 commit into
Conversation
…as not started The coordinator's cleanup loop cancels multiplexers with zero active subscriptions by invoking their cancelFunc. cancelFunc is only assigned by the watchResource goroutine, so a subscription that is registered and cancelled before watchResource runs leaves a multiplexer in the map with empty subs and a nil cancelFunc. The next cleanup tick then called the nil function and panicked, crashing flagd-proxy. Refactor the cleanup body into cleanupOnce and handle the nil case by removing the dead entry directly instead of calling a nil cancelFunc. Adds a regression test for a multiplexer whose watcher never started. Signed-off-by: Agi-Asi <206806952+Agi-Asi@users.noreply.github.com> Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
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.
This PR
Fixes a nil-pointer panic found while reviewing
flagd-proxy/pkg/service/subscriptions/manager.go.The coordinator's cleanup loop cancels multiplexers with zero active subscriptions by invoking their
cancelFunc.cancelFuncis only assigned by thewatchResourcegoroutine, so a subscription that is registered and then cancelled beforewatchResourceruns leaves a multiplexer in the map with an emptysubsmap and a nilcancelFunc. The next cleanup tick (every 5s) then called the nil function → panic → the whole flagd-proxy process crashes.This is a startup-window race: a client that connects and disconnects quickly (e.g. a provider retrying before the CR/source exists, or a flapping client) while the watcher goroutine has not been scheduled yet.
Changes
flagd-proxy/pkg/service/subscriptions/manager.gocleanupOnce().cancelFuncyet, remove the dead entry directly instead of calling a nil function (the watcher goroutine, when it eventually runs, finds no multiplexer and exits).flagd-proxy/pkg/service/subscriptions/manager_test.goTest_cleanupOnce_multiplexerWithoutStartedWatcherdrivescleanupOnce()against a multiplexer whose watcher never started and asserts no panic and removal of the entry.Related Issues
Related to the subscription-lifecycle work in open-feature#2030/open-feature#2031 (this is a distinct panic path in the same component).
How to test
Signed-off-by: Agi-Asi 206806952+Agi-Asi@users.noreply.github.com