-
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
Expose fault.http.abort.http_status setting via HTTP header #10294
Conversation
Signed-off-by: Rafal Augustyniak <raugustyniak@lyft.com>
Signed-off-by: Rafal Augustyniak <raugustyniak@lyft.com>
Signed-off-by: Rafal Augustyniak <raugustyniak@lyft.com>
Signed-off-by: Rafal Augustyniak <raugustyniak@lyft.com>
Signed-off-by: Rafal Augustyniak <raugustyniak@lyft.com>
Signed-off-by: Rafal Augustyniak <raugustyniak@lyft.com>
Signed-off-by: Rafal Augustyniak <raugustyniak@lyft.com>
Signed-off-by: Rafal Augustyniak <raugustyniak@lyft.com>
Signed-off-by: Rafal Augustyniak <raugustyniak@lyft.com>
Signed-off-by: Rafal Augustyniak <raugustyniak@lyft.com>
Signed-off-by: Rafal Augustyniak <raugustyniak@lyft.com>
Signed-off-by: Rafal Augustyniak <raugustyniak@lyft.com>
Signed-off-by: Rafal Augustyniak <raugustyniak@lyft.com>
Signed-off-by: Rafal Augustyniak <raugustyniak@lyft.com>
Signed-off-by: Rafal Augustyniak <raugustyniak@lyft.com>
Signed-off-by: Rafal Augustyniak <raugustyniak@lyft.com>
Signed-off-by: Rafal Augustyniak <raugustyniak@lyft.com>
Signed-off-by: Rafal Augustyniak <raugustyniak@lyft.com>
Signed-off-by: Rafal Augustyniak <raugustyniak@lyft.com>
Signed-off-by: Rafal Augustyniak <raugustyniak@lyft.com>
Signed-off-by: Rafal Augustyniak <raugustyniak@lyft.com>
Signed-off-by: Rafal Augustyniak <raugustyniak@lyft.com>
Signed-off-by: Rafal Augustyniak <raugustyniak@lyft.com>
Signed-off-by: Rafal Augustyniak <raugustyniak@lyft.com>
Signed-off-by: Rafal Augustyniak <raugustyniak@lyft.com>
@mattklein123 @htuch I think that I've addressed all of your comments. I have one question regarding tests. I've tried to add an integration unit tests to fault_filter_integration_test.cc file but every time I tried to inject an abort fault via HTTP header I ended up getting the following error while running tests:
It fails on A git patch that can be used to test this:
|
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.
Thanks, looks great with one small nit and test request. Nice work! In terms of adding an integration test, here is an example of a test that doesn't use an upstream, it just makes a request and expects a response:
envoy/test/integration/integration_test.cc
Line 182 in 9be85fb
TEST_P(IntegrationTest, ConnectionClose) { |
/wait
return ret; | ||
} | ||
|
||
if (code >= 200 and code < 600) { |
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.
nit: s/and/&& (some C++ compilers don't support it and it's not widely used), also please add some out of range tests.
Signed-off-by: Rafal Augustyniak <raugustyniak@lyft.com>
Thank you! I tried something like this but it just got stuck on // Request abort controlled via header configuration.
TEST_P(FaultIntegrationTestAllProtocols, HeaderFaultAbortConfig) {
initializeFilter(header_fault_config_);
codec_client_ = makeHttpConnection(lookupPort("http"));
auto response =
codec_client_->makeHeaderOnlyRequest(Http::TestRequestHeaderMapImpl{{":method", "GET"},
{":path", "/test/long/url"},
{":scheme", "http"},
{":authority", "host"},
{"connection", "close"},
{"x-envoy-fault-abort-request", "429"}});
response->waitForEndStream();
codec_client_->waitForDisconnect();
EXPECT_TRUE(response->complete());
EXPECT_THAT(response->headers(), Envoy::Http::HttpStatusIs("429"));
} Removal of |
Signed-off-by: Rafal Augustyniak <raugustyniak@lyft.com>
I'm not sure why your test is failing, but it's probably an actual issue. I would recommend running your test with debug tracing locally to debug a bit. Try the following bazel flags:
|
Signed-off-by: Rafal Augustyniak <raugustyniak@lyft.com>
HTTP headers used in integration test:
I was able to debug the test using the following command:
Debugging output:
I confirmed that
|
Thanks for trying the delay integration test. I think we can probably give up on it now, but before we do that, can you show a diff of your proposed test? Where are you putting the sim time advance? I think the issue is that you are likely advancing time before the actual timer is created, so it's racing, and you have no way of actually knowing when it's safe to advance time. If we keep a gauge of active faults that are currently delayed (?) you could probably wait on this gauge being 1 and that would work, but I'm not sure if we do that. cc @jmarantz. |
reserved 1; | ||
|
||
oneof error_type { | ||
option (validate.required) = true; | ||
|
||
// HTTP status code to use to abort the HTTP request. | ||
uint32 http_status = 2 [(validate.rules).uint32 = {lt: 600 gte: 200}]; | ||
|
||
// Fault aborts are controlled via an HTTP header (if applicable). | ||
HeaderAbort header_abort = 4; |
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.
I would call this header_error
. The abort is still controlled by the normal mechanisms, it's just the nature of the error is expressed in the header.
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.
I can change it but I think that header_abort
is a better name because:
header_error
can be in theory used to inject status codes such as200
or204
that are not errors.header_abort
follows a naming scheme used byheader_limit
andheader_delay
fields.header_error
would've been a better choice ifheader_limit
washeader_kbs
andheader_delay
washeader_duration
.
Thoughts?
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.
I think I would be inclined to stick with header_abort
for the reasons that @Augustyniak outlines. @htuch WDYT?
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.
Fair enough.
@@ -36,6 +36,9 @@ The fault filter has the capability to allow fault configuration to be specified | |||
This is useful in certain scenarios in which it is desired to allow the client to specify its own | |||
fault configuration. The currently supported header controls are: | |||
|
|||
* Request abort configuration via the *x-envoy-fault-abort-request* header. The header value | |||
should be an integer that specifies the HTTP status code to return in response to a request | |||
and must be in the range [200, 600). |
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.
Worth pointing out that header_abort
needs to be set (and including an RST link back to it).
Diff for the test I have problems with:
You were right, my time modification logic is racing with the logic responsible for delay injection and I end up modifying time before I schedule a timer. |
Signed-off-by: Rafal Augustyniak <raugustyniak@lyft.com>
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.
LGTM pending @htuch approval. Thank you!
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.
/lgtm api
Description: The partial implementation of #10254. Adding a support for http header responsible for injecting faults - aborting requests with
x-envoy-fault-abort-request
HTTP header set.Risk Level: low, new feature.
Testing: Added
Docs Changes: Added
Release Notes: Added