Skip to content
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

refactor http parser implementation in http_inspector #36430

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

vamshi177
Copy link

@vamshi177 vamshi177 commented Oct 3, 2024

Commit Message: refactor http parser implementation in http_inspector
Additional Description:
This update replaces the usage of the legacy http_parser in http_inspector with the LegacyHttpParserImpl as the first step in transitioning to the Balsa parser (part of #36433). The Parser interface is used with LegacyHttpParserImpl to preserve the current behaviour of http_parser.

Risk Level: Low (no behavioural change)
Testing: All the http_inspector tests have passed (bazel test //test/extensions/filters/listener/http_inspector/...)

Docs Changes:
Release Notes:
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
[Optional API Considerations:]

Copy link

Hi @vamshi177, welcome and thank you for your contribution.

We will try to review your Pull Request as quickly as possible.

In the meantime, please take a look at the contribution guidelines if you have not done so already.

🐱

Caused by: #36430 was opened by vamshi177.

see: more, trace.

Signed-off-by: G Vamshi Krishna Reddy <vamshikrishna.gunreddy@gmail.com>
@vamshi177 vamshi177 changed the title Replace http_parser with LegayParserImpl in http_inspector replace http_parser with LegayParserImpl in http_inspector Oct 3, 2024
@vamshi177 vamshi177 changed the title replace http_parser with LegayParserImpl in http_inspector replace http_parser with LegacyParserImpl in http_inspector Oct 3, 2024
@vamshi177 vamshi177 marked this pull request as draft October 3, 2024 14:18
@vamshi177 vamshi177 marked this pull request as ready for review October 4, 2024 06:31
@vamshi177 vamshi177 changed the title replace http_parser with LegacyParserImpl in http_inspector refactor http parser implementation in http_inspector Oct 4, 2024
Signed-off-by: G Vamshi Krishna Reddy <vamshikrishna.gunreddy@gmail.com>
@vamshi177
Copy link
Author

@yanavlasov @wbpcode Could you provide feedback on this change?

Recently, we encountered a use case that required support for custom methods. However, using http_protocol_options.allow_custom_methods didn't fully resolve the issue, as the requests were being rejected by the client Envoy at the http_inspector, which still uses http_parser and currently doesn't support custom methods.

To allow custom methods in http_inspector, as a first step, I am refactoring the parser code in http_inspector to use the Parser interface with LegacyHttpParserImpl. After that, I will implement a runtime feature flag to use BalsaParser.

@alyssawilk
Copy link
Contributor

/wait on CI
@wbpcode please remember to use wait tags if you're not reviewing due to CI failures, to keep this off the stale dashboard

@vamshi177
Copy link
Author

/retest

@alyssawilk
Copy link
Contributor

FWIW we had a permafail on main so this will almost certainly need a main merge now

@vamshi177
Copy link
Author

FWIW we had a permafail on main so this will almost certainly need a main merge now

Thanks for the info, will merge the changes from main now.

Signed-off-by: G Vamshi Krishna Reddy <vamshikrishna.gunreddy@gmail.com>
Signed-off-by: G Vamshi Krishna Reddy <vamshikrishna.gunreddy@gmail.com>
@wbpcode
Copy link
Member

wbpcode commented Oct 11, 2024

Code coverage for source/extensions/filters/listener is lower than limit of 96.6 (96.0)
Code coverage for source/extensions/filters/listener/http_inspector is lower than limit of 96.6 (86.2)

Hi, please check the coverage issue of CI. Thanks. The code LGTM, and thanks for this contribution!

/wait

@@ -24,13 +24,12 @@ Config::Config(Stats::Scope& scope)
const absl::string_view Filter::HTTP2_CONNECTION_PREFACE = "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n";

Filter::Filter(const ConfigSharedPtr config) : config_(config) {
http_parser_init(&parser_, HTTP_REQUEST);
// Filter for only Request Message types with NoOp callbacks
no_op_callbacks_ = std::make_unique<NoOpParserCallbacks>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that necessary to always do this heap allocation if this is an NoOp callabcks instance?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, As this is a NoOp callback instance, there is no need for heap allocation.
updated the PR.

Signed-off-by: G Vamshi Krishna Reddy <vamshikrishna.gunreddy@gmail.com>
@vamshi177
Copy link
Author

Code coverage for source/extensions/filters/listener is lower than limit of 96.6 (96.0)
Code coverage for source/extensions/filters/listener/http_inspector is lower than limit of 96.6 (86.2)

Hi, please check the coverage issue of CI. Thanks. The code LGTM, and thanks for this contribution!

/wait

working on adding more tests to increase coverage for http_inspector. will update the PR shortly.

@wbpcode
Copy link
Member

wbpcode commented Oct 12, 2024

@vamshi177 Thanks for your hard working. But we recently will cut a major release version, we could land the PR after that release. So, take it easy, it have enough time.

/wait

Filter::Filter(const ConfigSharedPtr config) : config_(config) {
http_parser_init(&parser_, HTTP_REQUEST);
Filter::Filter(const ConfigSharedPtr config) : config_(config), no_op_callbacks_() {
// Filter for only Request Message types with NoOp callbacks
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: add a '.' at the end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants