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

Fluent Bit still buffers to the filesystem if the folder in storage.path exists even if Emitter_Storage.type is set to memory #8259

Closed
lpugoy opened this issue Dec 7, 2023 · 2 comments · Fixed by #8290

Comments

@lpugoy
Copy link

lpugoy commented Dec 7, 2023

Bug Report

Describe the bug
If a rewrite tag filter has Emitter_Storage.type set to memory, Fluent Bit will act as if Emitter_Storage.type is set to filesystem if storage.path is set in the [SERVICE] section and the filter's folder exists.

I can confirm this also happens with inputs with Storage.type set to memory.

To Reproduce

Fluent Bit config

[SERVICE]
    storage.path /fluent-bit/data

[INPUT]
    Name dummy
    Tag dummy

[FILTER]
    Name rewrite_tag
    Match dummy
    Rule $message dummy rewritten false
    Emitter_Name rewriter
    Emitter_Storage.type memory

[OUTPUT]
    Name stdout
    Match rewritten
  • Steps to reproduce the problem:
  1. mkdir -p "$(pwd)/data/emitter.2"
  2. Watch for file system changes in the data directory: inotifywait in Linux or fswatch in Mac, for example.
  3. Run Fluent Bit: docker run --name fluentbit --rm -v $(pwd)/data:/fluent-bit/data:rw -v $(pwd)/fluentbit.conf:/config/fluentbit.conf:ro cr.fluentbit.io/fluent/fluent-bit:2.2.0 -c /config/fluentbit.conf.

Expected behavior
No files will be created under the data/emitter.2 directory.

Your Environment

  • Version used: 2.2.0
  • Configuration: Fluent Bit config given above
  • Environment name and version (e.g. Kubernetes? What version?): Docker
  • Server type and version: n/a
  • Operating System and version: n/a
  • Filters and plugins: n/a

Additional context
This makes having some inputs/rewrite filters use filesystem buffering while others use memory impossible.

@nokute78
Copy link
Collaborator

nokute78 commented Dec 9, 2023

@edsiper @leonardo-albertovich
cio_scan_streams from cio_load creates cio_stream and set storage_type to filesystem if storage.path is defined and sub directory is found.

mkdir -p "$(pwd)/data/emitter.2" means that fluent-bit create cio_stream for emitter.2 and its storage_type is filesystem before creating plugin instances.

We can't modify it since checking duplication.
https://github.com/fluent/fluent-bit/blob/v2.2.0/lib/chunkio/src/cio_stream.c#L145

nokute78 added a commit to nokute78/fluent-bit that referenced this issue Dec 16, 2023
cio_load creates storage stream if directory exists.
It prevents to create memory stream by input plugins.
This patch is to recreate stream if the type is different.

Signed-off-by: Takahiro Yamashita <[email protected]>
@nokute78
Copy link
Collaborator

I sent a patch #8290 .

edsiper pushed a commit that referenced this issue Jan 10, 2024
* storage: recreate cio_stream if storage type is different(#8259)

cio_load creates storage stream if directory exists.
It prevents to create memory stream by input plugins.
This patch is to recreate stream if the type is different.

Signed-off-by: Takahiro Yamashita <[email protected]>

* storage: modify log message

Signed-off-by: Takahiro Yamashita <[email protected]>

---------

Signed-off-by: Takahiro Yamashita <[email protected]>
shaerpour pushed a commit to shaerpour/fluent-bit that referenced this issue Jan 16, 2024
fluent#8290)

* storage: recreate cio_stream if storage type is different(fluent#8259)

cio_load creates storage stream if directory exists.
It prevents to create memory stream by input plugins.
This patch is to recreate stream if the type is different.

Signed-off-by: Takahiro Yamashita <[email protected]>

* storage: modify log message

Signed-off-by: Takahiro Yamashita <[email protected]>

---------

Signed-off-by: Takahiro Yamashita <[email protected]>
shaerpour pushed a commit to shaerpour/fluent-bit that referenced this issue Jan 16, 2024
fluent#8290)

* storage: recreate cio_stream if storage type is different(fluent#8259)

cio_load creates storage stream if directory exists.
It prevents to create memory stream by input plugins.
This patch is to recreate stream if the type is different.

Signed-off-by: Takahiro Yamashita <[email protected]>

* storage: modify log message

Signed-off-by: Takahiro Yamashita <[email protected]>

---------

Signed-off-by: Takahiro Yamashita <[email protected]>
Signed-off-by: ahspw <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants