Repository navigation
Return 404 from force-leave for nodes that are not cluster members - #24082
Open
Sanjays2402 wants to merge 2 commits into
Open
Sanjays2402 wants to merge 2 commits into
Sanjays2402 wants to merge 2 commits into
Conversation
|
Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement Learn more about why HashiCorp requires a CLA and what the CLA includes Have you signed the CLA already but the status is still pending? Recheck it. |
1 similar comment
|
Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement Learn more about why HashiCorp requires a CLA and what the CLA includes Have you signed the CLA already but the status is still pending? Recheck it. |
This branch has not been deployed
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.
Description
PUT /v1/agent/force-leave/<node>answered 500 when the named node did not exist. Both the client and the server remove paths already detected this case and produced a "No node found" error, but nothing set it apart from a genuine server failure, so the HTTP layer fell back to 500.This adds a small sentinel error in agent/consul for the not-found case, keeps the existing error text exactly as it was, and has the force-leave handler translate it into a 404 carrying the same message. The WAN path goes through the same handler, so it gets the same treatment.
Testing & Reproduction steps
Repro: start a single agent and run
curl -X PUT <addr>/v1/agent/force-leave/nonexistent-node. Before this change the response was 500; after, it is 404 withagent: No node found with name 'nonexistent-node'.Added
TestAgent_ForceLeave_UnknownNode, which drives the handler the same way the existing force-leave tests do and expects a 404. The existing force-leave tests still pass:TestAgent_ForceLeave,TestAgent_ForceLeave_ACLDeny,TestAgent_ForceLeavePrune, andTestAgent_ForceLeavePrune_WAN.Links
Fixes #21878
Note: the changelog entry follows as
.changelog/<PR number>.txtin a follow-up commit on this branch, since the file has to be named after the PR number.PR Checklist
PCI review checklist
I have documented a clear reason for, and description of, the change I am making.
If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request.
If applicable, I've documented the impact of any changes to security controls.