-
Notifications
You must be signed in to change notification settings - Fork 85
Cronvoy: Map EM Errors to Cronet API Errors (#1594) #2568
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
Merged
Merged
Changes from 12 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
103654c
Cronvoy: map EnvoyMobile Errors to cronet errors (#1549)
colibie 3805787
Merge branch 'envoyproxy:main' into cronvoy_errors
colibie b32e44b
[cronvoy] resolve PR comments
colibie 935327a
Merge branch 'main' of github.com:colibie/envoy-mobile into cronvoy_e…
colibie edbb3d8
[cronvoy] attempt to fix conflict
colibie 34d40a8
Merge branch 'main' of github.com:colibie/envoy-mobile into cronvoy_e…
colibie c197fb4
cronvoy: changing from hexString to int
colibie b5599fb
cronvoy: remove long conversion to hexString or int
colibie f5f7dc5
cronvoy: fix grammar
colibie d7a0d6a
cronvoy: refactor
colibie ac1877e
cronvoy: format
colibie dcaeeaa
cronvoy: change javadoc working
colibie e5d5085
Kick CI
colibie 59b7099
Kick CI
colibie 445d3ce
move test-read filter to test/ folder
colibie 24e1137
Merge branch 'main' into cronvoy_errors
colibie 8678bde
most test-only test read filter to test component
colibie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| load( | ||
| "@envoy//bazel:envoy_build_system.bzl", | ||
| "envoy_cc_extension", | ||
| "envoy_extension_package", | ||
| "envoy_proto_library", | ||
| ) | ||
|
|
||
| licenses(["notice"]) # Apache 2 | ||
|
|
||
| envoy_extension_package() | ||
|
|
||
| envoy_proto_library( | ||
| name = "filter", | ||
| srcs = ["filter.proto"], | ||
| deps = [ | ||
| "@envoy_api//envoy/config/common/matcher/v3:pkg", | ||
| ], | ||
| ) | ||
|
|
||
| envoy_cc_extension( | ||
| name = "test_read_filter_lib", | ||
| srcs = ["filter.cc"], | ||
| hdrs = ["filter.h"], | ||
| repository = "@envoy", | ||
| deps = [ | ||
| "filter_cc_proto", | ||
| "@envoy//source/common/http:utility_lib", | ||
| "@envoy//source/common/stream_info:stream_info_lib", | ||
| "@envoy//source/extensions/filters/http/common:pass_through_filter_lib", | ||
| ], | ||
| ) | ||
|
|
||
| envoy_cc_extension( | ||
| name = "config", | ||
| srcs = ["config.cc"], | ||
| hdrs = ["config.h"], | ||
| repository = "@envoy", | ||
| deps = [ | ||
| ":test_read_filter_lib", | ||
| "@envoy//source/extensions/filters/http/common:factory_base_lib", | ||
| ], | ||
| ) |
26 changes: 26 additions & 0 deletions
26
library/common/extensions/filters/http/test_read/config.cc
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| #include "library/common/extensions/filters/http/test_read/config.h" | ||
|
|
||
| #include "library/common/extensions/filters/http/test_read/filter.h" | ||
|
|
||
| namespace Envoy { | ||
| namespace Extensions { | ||
| namespace HttpFilters { | ||
| namespace TestRead { | ||
|
|
||
| Http::FilterFactoryCb TestReadFilterFactory::createFilterFactoryFromProtoTyped( | ||
| const envoymobile::extensions::filters::http::test_read::TestRead& /*config*/, | ||
| const std::string&, Server::Configuration::FactoryContext& /*context*/) { | ||
| return [](Http::FilterChainFactoryCallbacks& callbacks) -> void { | ||
| callbacks.addStreamDecoderFilter(std::make_shared<TestReadFilter>()); | ||
| }; | ||
| } | ||
|
|
||
| /** | ||
| * Static registration for the TestRead filter. @see NamedHttpFilterConfigFactory. | ||
| */ | ||
| REGISTER_FACTORY(TestReadFilterFactory, Server::Configuration::NamedHttpFilterConfigFactory); | ||
|
|
||
| } // namespace TestRead | ||
| } // namespace HttpFilters | ||
| } // namespace Extensions | ||
| } // namespace Envoy |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| #pragma once | ||
|
|
||
| #include <string> | ||
|
|
||
| #include "source/extensions/filters/http/common/factory_base.h" | ||
|
|
||
| #include "library/common/extensions/filters/http/test_read/filter.pb.h" | ||
| #include "library/common/extensions/filters/http/test_read/filter.pb.validate.h" | ||
|
|
||
| namespace Envoy { | ||
| namespace Extensions { | ||
| namespace HttpFilters { | ||
| namespace TestRead { | ||
|
|
||
| /** | ||
| * Config registration for the TestRead filter. @see NamedHttpFilterConfigFactory. | ||
| */ | ||
| class TestReadFilterFactory | ||
| : public Common::FactoryBase<envoymobile::extensions::filters::http::test_read::TestRead> { | ||
| public: | ||
| TestReadFilterFactory() : FactoryBase("test_read") {} | ||
|
|
||
| private: | ||
| ::Envoy::Http::FilterFactoryCb createFilterFactoryFromProtoTyped( | ||
| const envoymobile::extensions::filters::http::test_read::TestRead& config, | ||
| const std::string& stats_prefix, Server::Configuration::FactoryContext& context) override; | ||
| }; | ||
|
|
||
| DECLARE_FACTORY(TestReadFilterFactory); | ||
|
|
||
| } // namespace TestRead | ||
| } // namespace HttpFilters | ||
| } // namespace Extensions | ||
| } // namespace Envoy |
46 changes: 46 additions & 0 deletions
46
library/common/extensions/filters/http/test_read/filter.cc
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| #include "library/common/extensions/filters/http/test_read/filter.h" | ||
|
|
||
| #include "envoy/server/filter_config.h" | ||
|
|
||
| namespace Envoy { | ||
| namespace Extensions { | ||
| namespace HttpFilters { | ||
| namespace TestRead { | ||
|
|
||
| Http::FilterHeadersStatus TestReadFilter::decodeHeaders(Http::RequestHeaderMap& request_headers, | ||
| bool) { | ||
| // sample path is /failed?start=0x10000 | ||
| Http::Utility::QueryParams query_parameters = | ||
| Http::Utility::parseQueryString(request_headers.Path()->value().getStringView()); | ||
| uint64_t response_flag; | ||
| if (absl::SimpleAtoi(query_parameters.at("start"), &response_flag)) { | ||
| decoder_callbacks_->streamInfo().setResponseFlag( | ||
| TestReadFilter::mapErrorToResponseFlag(response_flag)); | ||
| decoder_callbacks_->sendLocalReply(Http::Code::BadRequest, "test_read filter threw: ", nullptr, | ||
| absl::nullopt, ""); | ||
| } | ||
| return Http::FilterHeadersStatus::StopIteration; | ||
| } | ||
|
|
||
| StreamInfo::ResponseFlag TestReadFilter::mapErrorToResponseFlag(uint64_t errorCode) { | ||
| switch (errorCode) { | ||
| case 0x4000000: | ||
| return StreamInfo::DnsResolutionFailed; | ||
| case 0x40: | ||
| return StreamInfo::UpstreamConnectionTermination; | ||
| case 0x20: | ||
| return StreamInfo::UpstreamConnectionFailure; | ||
| case 0x10: | ||
| return StreamInfo::UpstreamRemoteReset; | ||
| case 0x10000: | ||
| return StreamInfo::StreamIdleTimeout; | ||
| default: | ||
| // Any other error that we aren't interested in. I picked a random error. | ||
| return StreamInfo::RateLimitServiceError; | ||
| } | ||
| } | ||
|
|
||
| } // namespace TestRead | ||
| } // namespace HttpFilters | ||
| } // namespace Extensions | ||
| } // namespace Envoy | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| #pragma once | ||
|
|
||
| #include "envoy/http/filter.h" | ||
|
|
||
| #include "source/common/common/logger.h" | ||
| #include "source/common/http/utility.h" | ||
| #include "source/common/stream_info/stream_info_impl.h" | ||
| #include "source/extensions/filters/http/common/pass_through_filter.h" | ||
|
|
||
| #include "library/common/extensions/filters/http/test_read/filter.pb.h" | ||
|
|
||
| namespace Envoy { | ||
| namespace Extensions { | ||
| namespace HttpFilters { | ||
| namespace TestRead { | ||
|
|
||
| /** | ||
| * Filter to return specified error code based on a request header. | ||
|
colibie marked this conversation as resolved.
Outdated
|
||
| */ | ||
| class TestReadFilter final : public Http::PassThroughFilter, | ||
|
colibie marked this conversation as resolved.
|
||
| public Logger::Loggable<Logger::Id::filter> { | ||
| public: | ||
| Http::FilterHeadersStatus decodeHeaders(Http::RequestHeaderMap& request_headers, bool) override; | ||
|
|
||
| private: | ||
| /* A mapping of the envoymobile errors we care about for testing | ||
| * From https://github.com/envoyproxy/envoy/blob/main/envoy/stream_info/stream_info.h | ||
| */ | ||
| StreamInfo::ResponseFlag mapErrorToResponseFlag(uint64_t errorCode); | ||
| }; | ||
|
|
||
| } // namespace TestRead | ||
| } // namespace HttpFilters | ||
| } // namespace Extensions | ||
| } // namespace Envoy | ||
8 changes: 8 additions & 0 deletions
8
library/common/extensions/filters/http/test_read/filter.proto
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| syntax = "proto3"; | ||
|
|
||
| package envoymobile.extensions.filters.http.test_read; | ||
|
|
||
| import "validate/validate.proto"; | ||
|
|
||
| message TestRead { | ||
| } |
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
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
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.