fix(http): avoid marking nodes down on client errors - #360
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThis PR introduces a typed error for client-side HTTP failures (400/401/404/405) to prevent unnecessary server downtime marking. The ChangesClient Request Error Differentiation
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
|
感谢您提出Pull Request,我会尽快Review。我会在1-2日内进行查看或者回复,如果遇到节假日可能会处理较慢,敬请谅解。 |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bf289294da
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| case http.StatusBadRequest, http.StatusUnauthorized, http.StatusNotFound, http.StatusMethodNotAllowed: | ||
| log.Errorf("Connect Apollo Server Fail, url:%s, StatusCode:%d", requestURL, res.StatusCode) | ||
| return nil, errors.New(fmt.Sprintf("Connect Apollo Server Fail, StatusCode:%d", res.StatusCode)) | ||
| return nil, &clientRequestInvalidError{statusCode: res.StatusCode} |
There was a problem hiding this comment.
Treat forbidden responses as client errors
When Apollo returns another client-side status such as 403 Forbidden for an unauthorized app/namespace, this still falls through to the retrying default case and RequestRecovery will call SetDownNode, marking a healthy node down for a bad request/permission issue. Apollo documents 403 as a client authorization error alongside 400/401/404/405 (https://github.com/apolloconfig/apollo/wiki/Apollo%E5%BC%80%E6%94%BE%E5%B9%B3%E5%8F%B0#%E5%9B%9B%E9%94%99%E8%AF%AF%E7%A0%81%E8%AF%B4%E6%98%8E), so this fix should classify the full non-retryable 4xx range (or at least include 403) before marking nodes down.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Pull request overview
This PR adjusts Apollo HTTP request handling to treat specific 4xx responses as client-side request errors, preventing those responses from incorrectly triggering node down-marking and cascading impact to other namespaces.
Changes:
- Introduces a dedicated
clientRequestInvalidErrorfor selected 4xx status codes (400/401/404/405). - Updates
RequestRecovery()to avoid callingserver.SetDownNode(...)when the failure is a client-side 4xx error. - Expands status-code tests to validate both “marked down” behavior and the new invalid-request classification.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| protocol/http/request.go | Adds a typed error for selected 4xx responses and prevents node down-marking for those errors in recovery logic. |
| protocol/http/request_test.go | Extends fail-fast status code tests to cover both client (4xx) and server (5xx) behaviors, including node down state assertions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| func (e *clientRequestInvalidError) Error() string { | ||
| return fmt.Sprintf("Connect Apollo Server Fail, StatusCode:%d", e.statusCode) | ||
| } |
| if expectedDurationZero { | ||
| Assert(t, int64(0), Equal(duration)) | ||
| } else { | ||
| Assert(t, int64(10), Equal(duration)) | ||
| } |
|
这个 PR 发生了冲突. @lemonel 是否能帮忙修复呢? 🙏 |
|
@copilot resolve the merge conflicts in this pull request |
Summary
Why
Summary by CodeRabbit