-
Notifications
You must be signed in to change notification settings - Fork 5.3k
ratelimit: add support for failure_mode_allow configuration #4073
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f0a6a88
84b081a
88e49e6
83e75ec
ef281ad
91439ea
2934cc4
37b6913
a6ca282
6296e00
3289db0
cf357e2
d561b19
4404df2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -147,6 +147,15 @@ void Filter::complete(RateLimit::LimitStatus status, Http::HeaderMapPtr&& header | |
| callbacks_->sendLocalReply(Http::Code::TooManyRequests, "", | ||
| [this](Http::HeaderMap& headers) { addHeaders(headers); }); | ||
| callbacks_->requestInfo().setResponseFlag(RequestInfo::ResponseFlag::RateLimited); | ||
| } else if (status == RateLimit::LimitStatus::Error) { | ||
| if (config_->failureModeAllow()) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did not change the method name in config because it seems more readable like this. LMK if you think otherwise
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is fine as is |
||
| cluster_->statsScope().counter("ratelimit.failure_mode_allowed").inc(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need this new counter at all? We already have a counter for ratelimit service failures, and presumably the user knows which way they have this configured (failure_mode_deny value). In one case this counter will always be zero, in the other it will be equal to
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this would help in general, while looking at stats user do not have to check back on what his configuration is.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I'm fine with that. |
||
| callbacks_->continueDecoding(); | ||
| } else { | ||
| state_ = State::Responded; | ||
| callbacks_->sendLocalReply(Http::Code::InternalServerError, "", nullptr); | ||
| callbacks_->requestInfo().setResponseFlag(RequestInfo::ResponseFlag::RateLimitServiceError); | ||
| } | ||
| } else if (!initiating_call_) { | ||
| callbacks_->continueDecoding(); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -813,11 +813,12 @@ name: envoy.file_access_log | |
| - FI | ||
| - RL | ||
| - UAEX | ||
| - RLSE | ||
| config: | ||
| path: /dev/null | ||
| )EOF"; | ||
|
|
||
| static_assert(RequestInfo::ResponseFlag::LastFlag == 0x1000, | ||
| static_assert(RequestInfo::ResponseFlag::LastFlag == 0x2000, | ||
| "A flag has been added. Fix this code."); | ||
|
|
||
| std::vector<RequestInfo::ResponseFlag> all_response_flags = { | ||
|
|
@@ -834,6 +835,7 @@ name: envoy.file_access_log | |
| RequestInfo::ResponseFlag::FaultInjected, | ||
| RequestInfo::ResponseFlag::RateLimited, | ||
| RequestInfo::ResponseFlag::UnauthorizedExternalService, | ||
| RequestInfo::ResponseFlag::RateLimitServiceError, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm going to take a look in the morning.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great Catch. I see the problem. The hex value I gave for |
||
| }; | ||
|
|
||
| InstanceSharedPtr log = AccessLogFactory::fromProto(parseAccessLogFromV2Yaml(yaml), context_); | ||
|
|
@@ -863,7 +865,7 @@ name: envoy.file_access_log | |
| "Proto constraint validation failed (AccessLogFilterValidationError.ResponseFlagFilter: " | ||
| "[\"embedded message failed validation\"] | caused by " | ||
| "ResponseFlagFilterValidationError.Flags[i]: [\"value must be in list \" [\"LH\" \"UH\" " | ||
| "\"UT\" \"LR\" \"UR\" \"UF\" \"UC\" \"UO\" \"NR\" \"DI\" \"FI\" \"RL\" \"UAEX\"]]): " | ||
| "\"UT\" \"LR\" \"UR\" \"UF\" \"UC\" \"UO\" \"NR\" \"DI\" \"FI\" \"RL\" \"UAEX\" \"RLSE\"]]): " | ||
| "response_flag_filter {\n flags: \"UnsupportedFlag\"\n}\n"); | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
failure_mode_deny: I'm fine with the stat being named either way, but the doc link needs to be updated.