fix(api): avoid double response on GET /api/cluster when HA is off#3887
Draft
cursor[bot] wants to merge 1 commit into
Draft
fix(api): avoid double response on GET /api/cluster when HA is off#3887cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
getClusterStatus wrote a 200 response for non-HA deployments but fell through to the nil-inspector branch, causing a second write (503) and invalid responses for GET /api/cluster. Return immediately after the minimal payload and align the unit test with the documented behavior. Co-authored-by: Denis Gukov <fiftin@outlook.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.
Bug and impact
getClusterStatusattempted to send two HTTP responses when high availability was disabled: first200with{"ha_enabled": false}, then503because the cluster inspector is absent in that configuration. That violatesnet/httpresponse semantics and produced broken or inconsistent responses for non-HA installs hittingGET /api/cluster(for example from the cluster dashboard or admin tooling).Root cause
Commit
da6c357cadded an earlyWriteJSONfor the non-HA case but omittedreturn, and placednode_idafter that block so the handler always continued into the nil-inspector error path.Fix and validation
!util.HAEnabled(), and populatenode_idbefore that branch whenutil.Config.HAis set.TestGetClusterStatus_HADisabledto expect200,ha_enabled: false, and nonodes/rediskeys.Tests:
mkdir -p api/public && touch api/public/.keep && go test ./api/...(theapi/publicplaceholder satisfies thego:embedpattern in this checkout).