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

Adds support for Content-Encoding: gzip to in_http #7667

Merged
merged 1 commit into from Mar 12, 2024

Conversation

erhudy
Copy link
Contributor

@erhudy erhudy commented Jul 8, 2023

This change adds support for gzipped content to in_http. I discovered this by accident when attempting to send gzipped JSON from another fluent-bit, and found that fluent-bit responded with an invalid JSON error. With this PR, fluent-bit will now appropriately handle gzipped content on the HTTP input.


Enter [N/A] in the box, if an item is not applicable to your change.

Testing
Before we can approve your change; please submit the following in a comment:

  • Example configuration file for the change
  • Debug log output from testing the change
  • Attached Valgrind output that shows no leaks or memory corruption was found

If this is a change to packaging of containers or native binaries then please confirm it works for all targets.

  • Run local packaging test showing all targets (including any new ones) build.
  • Set ok-package-test label to test for all targets (requires maintainer to do).

Documentation

  • Documentation required for this feature

Backporting

  • Backport to latest stable release.

Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.

@erhudy
Copy link
Contributor Author

erhudy commented Jul 8, 2023

Valgrind output:

==103116== Memcheck, a memory error detector
==103116== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==103116== Using Valgrind-3.19.0 and LibVEX; rerun with -h for copyright info
==103116== Command: bin/fluent-bit -i http -o stdout
==103116== 
Fluent Bit v2.1.7
* Copyright (C) 2015-2022 The Fluent Bit Authors
* Fluent Bit is a CNCF sub-project under the umbrella of Fluentd
* https://fluentbit.io

[2023/07/07 22:18:08] [ info] [fluent bit] version=2.1.7, commit=02a1b386d1, pid=103116
[2023/07/07 22:18:08] [ info] [storage] ver=1.4.0, type=memory, sync=normal, checksum=off, max_chunks_up=128
[2023/07/07 22:18:08] [ info] [cmetrics] version=0.6.3
[2023/07/07 22:18:08] [ info] [ctraces ] version=0.3.1
[2023/07/07 22:18:08] [ info] [input:http:http.0] initializing
[2023/07/07 22:18:08] [ info] [input:http:http.0] storage_strategy='memory' (memory only)
[2023/07/07 22:18:09] [ info] [sp] stream processor started
[2023/07/07 22:18:09] [ info] [output:stdout:stdout.0] worker #0 started
[0] http.0: [[1688782691.385651035, {}], {"hello"=>"what"}]
[0] http.0: [[1688782720.546720821, {}], {"hello"=>"gzipped what"}]
^C[2023/07/07 22:18:49] [engine] caught signal (SIGINT)
[2023/07/07 22:18:49] [ warn] [engine] service will shutdown in max 5 seconds
[2023/07/07 22:18:50] [ info] [engine] service has stopped (0 pending tasks)
[2023/07/07 22:18:50] [ info] [output:stdout:stdout.0] thread worker #0 stopping...
[2023/07/07 22:18:50] [ info] [output:stdout:stdout.0] thread worker #0 stopped
==103116== 
==103116== HEAP SUMMARY:
==103116==     in use at exit: 0 bytes in 0 blocks
==103116==   total heap usage: 1,709 allocs, 1,709 frees, 3,672,189 bytes allocated
==103116== 
==103116== All heap blocks were freed -- no leaks are possible
==103116== 
==103116== For lists of detected and suppressed errors, rerun with: -s
==103116== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

Commands I ran to test:

non-gzipped:

curl -d '{"hello": "what"}' -H "Content-Type: application/json" http://localhost:9880

gzipped:

echo '{"hello": "gzipped what"}' | gzip > body.gz;  curl --data-binary @body.gz -H "Content-Type: application/json" -H "Content-Encoding: gzip" http://localhost:9880

Invalid content-encoding header:

echo '{"hello": "gzipped what"}' | gzip > body.gz;  curl --data-binary @body.gz -H "Content-Type: application/json" -H "Content-Encoding: gozip" http://localhost:9880

(this results in no output in the fluent-bit log and returns error: invalid 'Content-Encoding' to the caller)

@erhudy
Copy link
Contributor Author

erhudy commented Jul 8, 2023

No config file is required to test this: I just ran bin/fluent-bit -i http -o stdout and used the default settings to test. I don't think this needs to be configurable behavior because it transparently handles gzipped input that previously failed, with no change to existing input.

@erhudy erhudy temporarily deployed to pr July 10, 2023 12:04 — with GitHub Actions Inactive
@erhudy erhudy temporarily deployed to pr July 10, 2023 12:04 — with GitHub Actions Inactive
@erhudy erhudy temporarily deployed to pr July 10, 2023 12:04 — with GitHub Actions Inactive
@erhudy erhudy temporarily deployed to pr July 10, 2023 12:27 — with GitHub Actions Inactive
@edsiper edsiper added this to the Fluent Bit v2.1.8 milestone Jul 18, 2023
@edsiper
Copy link
Member

edsiper commented Jul 20, 2023

@erhudy would you please fix the conflict ?

@erhudy
Copy link
Contributor Author

erhudy commented Jul 22, 2023

@erhudy would you please fix the conflict ?

Reconciled.

@edsiper
Copy link
Member

edsiper commented Jul 24, 2023

@leonardo-albertovich pls review

@erhudy erhudy temporarily deployed to pr July 24, 2023 04:40 — with GitHub Actions Inactive
@erhudy erhudy temporarily deployed to pr July 24, 2023 04:40 — with GitHub Actions Inactive
@erhudy erhudy temporarily deployed to pr July 24, 2023 04:40 — with GitHub Actions Inactive
@erhudy erhudy temporarily deployed to pr July 24, 2023 05:06 — with GitHub Actions Inactive
@erhudy
Copy link
Contributor Author

erhudy commented Sep 26, 2023

Anything you need from me on this PR right now? I've had this in production at my company since I made this PR and in almost 4 months it's just been doing the thing I expect it to do.

Copy link
Contributor

@cosmo0920 cosmo0920 left a comment

Choose a reason for hiding this comment

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

The logic seems good but I added some concerns to proceed the PR.

plugins/in_http/http_prot.c Outdated Show resolved Hide resolved
plugins/in_http/http_prot.c Outdated Show resolved Hide resolved
plugins/in_http/http_prot.c Outdated Show resolved Hide resolved
@lecaros lecaros removed this from the Fluent Bit v2.1.10 milestone Sep 27, 2023
@patrick-stephens
Copy link
Contributor

Could you rebase @erhudy as it looks like there were some issues running actions (possibly a Github outage at the time)?

@patrick-stephens
Copy link
Contributor

@leonardo-albertovich are you ok with this?

@erhudy
Copy link
Contributor Author

erhudy commented Nov 14, 2023

Could you rebase @erhudy as it looks like there were some issues running actions (possibly a Github outage at the time)?

Rebased.

@patrick-stephens
Copy link
Contributor

There we go, got unit tests running now.

@erhudy
Copy link
Contributor Author

erhudy commented Nov 14, 2023

@patrick-stephens it looks like 2/3 macOS test suites failed. I don't see an indication that it's related to my changes, but I don't have permission to rerun just those actions.

@erhudy
Copy link
Contributor Author

erhudy commented Nov 18, 2023

Added fluent/fluent-bit-docs#1260 for documentation change.

@cosmo0920
Copy link
Contributor

cosmo0920 commented Nov 20, 2023

I don't see an indication that it's related to my changes, but I don't have permission to rerun just those actions.

Currently, macOS tests are flaky. Feel free to ignore them. Instead, please pay attention to Ubuntu unit tests and Windows builds.

Signed-off-by: Edmund Rhudy <erhudy@users.noreply.github.com>
@edsiper edsiper merged commit 4b38a2a into fluent:master Mar 12, 2024
6 checks passed
@edsiper
Copy link
Member

edsiper commented Mar 12, 2024

thank you!

please make sure to adjust commits for further contributions: https://github.com/fluent/fluent-bit/blob/master/CONTRIBUTING.md#commit-changes

cosmo0920 pushed a commit that referenced this pull request Mar 13, 2024
Signed-off-by: Edmund Rhudy <erhudy@users.noreply.github.com>
edsiper pushed a commit that referenced this pull request Mar 14, 2024
Signed-off-by: Edmund Rhudy <erhudy@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants