Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/fluentbit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ on:
paths:
- .github/workflows/fluentbit.yaml
- images/fluentbit/Dockerfile
- images/fluentbit/*.patch
pull_request:
paths:
- .github/workflows/fluentbit.yaml
- images/fluentbit/Dockerfile
- images/fluentbit/*.patch

permissions:
contents: read
Expand Down Expand Up @@ -48,3 +50,23 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

- uses: docker/metadata-action@v5
id: meta-debug
with:
images: ghcr.io/yolean/fluentbit
tags: |
type=raw,value=debug-${{ github.sha }}

- uses: docker/build-push-action@v6
with:
context: images/fluentbit
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name == 'push' }}
tags: ${{ steps.meta-debug.outputs.tags }}
labels: ${{ steps.meta-debug.outputs.labels }}
build-args: |
FLB_TRACE=On
FLB_HTTP_CLIENT_DEBUG=On
cache-from: type=gha
cache-to: type=gha,mode=max
1 change: 1 addition & 0 deletions images/fluentbit/.dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*
!*.patch
9 changes: 8 additions & 1 deletion images/fluentbit/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
FROM debian:trixie@sha256:2c91e484d93f0830a7e05a2b9d92a7b102be7cab562198b984a84fdbc7806d91 AS build

ARG FLB_VERSION=v4.2.2
ARG FLB_TRACE=Off
ARG FLB_HTTP_CLIENT_DEBUG=Off

RUN set -ex; \
export DEBIAN_FRONTEND=noninteractive; \
Expand Down Expand Up @@ -39,10 +41,15 @@ RUN set -ex; \

RUN git clone --depth 1 --branch $FLB_VERSION https://github.com/fluent/fluent-bit.git /src/fluent-bit

COPY *.patch /src/
RUN cd /src/fluent-bit && git apply /src/*.patch

WORKDIR /src/fluent-bit/build

RUN cmake \
-DFLB_RELEASE=On \
-DFLB_TRACE=${FLB_TRACE} \
-DFLB_HTTP_CLIENT_DEBUG=${FLB_HTTP_CLIENT_DEBUG} \
-DFLB_JEMALLOC=On \
-DFLB_TLS=On \
-DFLB_SHARED_LIB=Off \
Expand Down Expand Up @@ -80,7 +87,7 @@ RUN set -ex; \
done; \
ls "$LIBDIR"

FROM gcr.io/distroless/cc-debian13:nonroot@sha256:5c94e1d2e831f0fadfe4048427f6ff3a91481606da2841c5b26674220ac84d2d
FROM gcr.io/distroless/cc-debian13:nonroot@sha256:84fcd3c223b144b0cb6edc5ecc75641819842a9679a3a58fd6294bec47532bf7

COPY --from=build /fluent-bit/bin/fluent-bit /usr/local/bin/
COPY --from=build /fluent-bit/etc/ /fluent-bit/etc/
Expand Down
22 changes: 22 additions & 0 deletions images/fluentbit/fix-gcs-header-lookup.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
diff --git a/src/flb_http_client.c b/src/flb_http_client.c
--- a/src/flb_http_client.c
+++ b/src/flb_http_client.c
@@ -477,8 +477,16 @@ static int header_lookup(struct flb_http_client *c,
return FLB_HTTP_MORE;
}

- /* Lookup the beginning of the header */
- p = strcasestr(c->resp.data, header);
+ /* Lookup the beginning of the header, ensuring it starts a line.
+ * GCS returns x-goog-stored-content-length before Content-Length;
+ * strcasestr matches "Content-Length" inside the longer header name. */
+ p = c->resp.data;
+ while ((p = strcasestr(p, header)) != NULL) {
+ if (p == c->resp.data || *(p - 1) == '\n') {
+ break;
+ }
+ p++;
+ }
end = strstr(c->resp.data, "\r\n\r\n");
if (!p) {
if (end) {