-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Fault injection filter #219
Changes from 1 commit
c6ba483
e222bf2
0330789
e599ab3
5a9bb24
db749c5
1740094
4c349c0
5f3d0e1
8eac972
57f3116
d836100
415321a
8b920ec
251661a
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 |
---|---|---|
|
@@ -17,11 +17,6 @@ FaultFilterConfig::FaultFilterConfig(const Json::Object& json_config, Runtime::L | |
const std::string& stat_prefix, Stats::Store& stats) | ||
: runtime_(runtime), stats_{ALL_FAULT_FILTER_STATS(POOL_COUNTER_PREFIX(stats, stat_prefix))} { | ||
|
||
abort_percent_ = 0UL; | ||
http_status_ = 0UL; | ||
fixed_delay_percent_ = 0UL; | ||
fixed_duration_ms_ = 0UL; | ||
|
||
if (json_config.hasObject("abort")) { | ||
const Json::Object& abort = json_config.getObject("abort"); | ||
abort_percent_ = static_cast<uint64_t>(abort.getInteger("abort_percent", 0)); | ||
|
@@ -101,11 +96,7 @@ FilterHeadersStatus FaultFilter::decodeHeaders(HeaderMap& headers, bool) { | |
|
||
if (config_->runtime().snapshot().featureEnabled("fault.http.abort.abort_percent", | ||
config_->abortPercent())) { | ||
// todo check http status codes obtained from runtime | ||
Http::HeaderMapPtr response_headers{new HeaderMapImpl{ | ||
{Headers::get().Status, std::to_string(config_->runtime().snapshot().getInteger( | ||
"fault.http.abort.http_status", config_->abortCode()))}}}; | ||
callbacks_->encodeHeaders(std::move(response_headers), true); | ||
abortWithHTTPStatus(); | ||
config_->stats().aborts_injected_.inc(); | ||
return FilterHeadersStatus::StopIteration; | ||
} | ||
|
@@ -133,17 +124,22 @@ void FaultFilter::postDelayInjection() { | |
// Delays can be followed by aborts | ||
if (config_->runtime().snapshot().featureEnabled("fault.http.abort.abort_percent", | ||
config_->abortPercent())) { | ||
Http::HeaderMapPtr response_headers{new HeaderMapImpl{ | ||
{Headers::get().Status, std::to_string(config_->runtime().snapshot().getInteger( | ||
"fault.http.abort.http_status", config_->abortCode()))}}}; | ||
abortWithHTTPStatus(); | ||
config_->stats().aborts_injected_.inc(); | ||
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. should go in abortWithHTTPStatus() 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. The reason I left it out of that function was because in future, we might add 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 would just move it for now. We can deal with the future when it happens. :) |
||
callbacks_->encodeHeaders(std::move(response_headers), true); | ||
} else { | ||
// Continue request processing | ||
callbacks_->continueDecoding(); | ||
} | ||
} | ||
|
||
void FaultFilter::abortWithHTTPStatus() { | ||
// TODO: check http status codes obtained from runtime | ||
Http::HeaderMapPtr response_headers{new HeaderMapImpl{ | ||
{Headers::get().Status, std::to_string(config_->runtime().snapshot().getInteger( | ||
"fault.http.abort.http_status", config_->abortCode()))}}}; | ||
callbacks_->encodeHeaders(std::move(response_headers), true); | ||
} | ||
|
||
void FaultFilter::resetTimerState() { | ||
if (delay_timer_) { | ||
delay_timer_->disableTimer(); | ||
|
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.
should go in abortWithHTTPStatus()