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

windows: build docker image with out_kafka and gzip #6214

Closed
wants to merge 16 commits into from

Conversation

alt-dima
Copy link


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.

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.

@alt-dima
Copy link
Author

alt-dima commented Oct 16, 2022

Probably this PR will be rejected, no problem.
just trying to help another devops to build fluent-bit with out_kafka plugin for windows

My changes

  1. I was not luck to enable cmake -DFLB_OUT_KAFKA=On (cmake just ignored it), changed option in cmake/windows-setup.cmake and it worked
  2. ENTRYPOINT and CMD was fixed in dockerfiles/Dockerfile.windows, because \ must be escaped. Without this fix container was not able to start with error "can not find the file specified" (in Kubernetes)
  3. lib/librdkafka-1.9.2/src/rdkafka_ssl.c was fixed for proper ssl libraries from version 1.1.1
  4. plugins/out_kafka/CMakeLists.txt fixed to remove lpthread if building with MSVC

@alt-dima
Copy link
Author

@patrick-stephens can you, please, take a look?
Is windows docker image works completely as expected without all those changes for you?

@alt-dima
Copy link
Author

alt-dima commented Oct 16, 2022

Just checked my image in Kubernetes (with fluentbit helm chart)

Fluent Bit v2.0.0
* Copyright (C) 2015-2022 The Fluent Bit Authors
* Fluent Bit is a CNCF sub-project under the umbrella of Fluentd
* https://fluentbit.io

[2022/10/16 15:51:39] [ warn] [config] I cannot open C:\fluent-bit\etc\/C:\fluent-bit\etc\parsers.conf file
[2022/10/16 15:51:39] [ info] [fluent bit] version=2.0.0, commit=, pid=252
[2022/10/16 15:51:39] [ info] [storage] ver=1.3.0, type=memory, sync=normal, checksum=off, max_chunks_up=128
[2022/10/16 15:51:39] [ info] [cmetrics] version=0.5.2
[2022/10/16 15:51:39] [ info] [input:tail:tail.0] initializing
[2022/10/16 15:51:39] [ info] [input:tail:tail.0] storage_strategy='memory' (memory only)
[2022/10/16 15:51:39] [ info] [input:tail:tail.0] multiline core started
[2022/10/16 15:51:39] [ info] [filter:kubernetes:kubernetes.0] https=1 host=kubernetes.default.svc.cluster.local port=443
[2022/10/16 15:51:39] [ info] [filter:kubernetes:kubernetes.0]  token updated
[2022/10/16 15:51:39] [ info] [filter:kubernetes:kubernetes.0] local POD info OK
[2022/10/16 15:51:40] [ info] [filter:kubernetes:kubernetes.0] host: kubernetes.default.svc.cluster.local Wait 30 secs until DNS starts up (1/6)
[2022/10/16 15:52:10] [ info] [filter:kubernetes:kubernetes.0] testing connectivity with API server...
[2022/10/16 15:52:10] [ info] [filter:kubernetes:kubernetes.0] connectivity OK
[2022/10/16 15:52:10] [ info] [input:emitter:emitter_for_rewrite_tag.4] initializing
[2022/10/16 15:52:10] [ info] [input:emitter:emitter_for_rewrite_tag.4] storage_strategy='memory' (memory only)
[2022/10/16 15:52:10] [error] [flb_kafka] cannot configure 'compression.type' property
[2022/10/16 15:52:10] [ info] [output:kafka:kafka.0] brokers='b-1.stagis.com:9092' topics='app-logs'
[2022/10/16 15:52:10] [error] [flb_kafka] cannot configure 'compression.type' property
[2022/10/16 15:52:10] [ info] [output:kafka:kafka.1] brokers='b-1.staging1kafkaops.com:9092' topics='app-metrics'
[2022/10/16 15:52:10] [ info] [http_server] listen iface=0.0.0.0 tcp_port=2020
[2022/10/16 15:52:10] [ info] [sp] stream processor started

Started successfully with kafka_out plugin!

Current problems

  • [warn] [config] I cannot open C:\fluent-bit\etc\/C:\fluent-bit\etc\parsers.conf file = because of volumeMounts specific implementation in Windows containers, I mount completely etc folder and loose all the files.
    Workaround = copy content of parsers.conf to customParsers in helm config.yaml
Error: Error response from daemon: invalid volume specification: 'c:\var\lib\kubelet\pods\88ae9a4a-df0d-41c6-af72-fd44047753db\volumes\kubernetes.io~configmap\config\fluent-b │
│ it.conf:c:/fluent-bit/etc/fluent-bit.conf:ro': invalid mount config for type "bind": source path must be a directory
  • Liveness probe shoul be with delay 2-5 min because of network delay in windows container = fixed with initialDelaySeconds: 180 in values.yaml in helm chart
  • [error] [flb_kafka] cannot configure 'compression.type' property = added Zlib installation and compilation to the dockerfile
  • actually logs are not being ready by fluent-bit because of Windows file permissions/location. No access to the docker log files
PS C:\var\log\containers> cat win-fluent-bit-9h8dw_logging_fluent-bit-e17294a03115c2b2bebc1624c7e850d80fe643f8b52d22d432720d7acbbd3270.log                                                                                                                  
cat : Could not find a part of the path 'C:\var\log\containers\win-fluent-bit-9h8dw_logging_fluent-bit-e17294a03115c2b2bebc1624c7e850d80fe643f8b52d22d432720d7acbbd3270.log'.

Fixed with proper/additional volume mounts

daemonSetVolumeMounts:
  - name: var
    mountPath: /var
    readOnly: true
  - name: docker
    mountPath: /ProgramData/docker/containers
    readOnly: true
  • Logs are coming without any kubernetes fields because of wrong pod name search in API (proper pod name is rms-adhd-web-7f797b678f-mdsjc)
 [2022/10/16 18:22:41] [debug] [filter:kubernetes:kubernetes.0] Request (ns=default, pod=s.rms-adhd-web-7f797b678f-mdsjc) http_do=0, HTTP Status: 404                                                                                                     │
│ [2022/10/16 18:22:41] [debug] [filter:kubernetes:kubernetes.0] HTTP response                                                                                                                                                                             │
│ {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"pods \"s.rms-adhd-web-7f797b678f-mdsjc\" not found","reason":"NotFound","details":{"name":"s.rms-adhd-web-7f797b678f-mdsjc","kind":"pods"},"code":404} 

Fixed with correct Kube_Tag_Prefix application.c.var.log.containers. (before it was like for Linux Kube_Tag_Prefix application.var.log.containers.)

@patrick-stephens
Copy link
Contributor

The Windows containers are not officially released or supported by the OSS project, they are provided primarily for reference but good to ensure they work. I do have a separate PR to provide OpenSSL as well but this was only around getting it to build so happy to have a better fix that verifies the container runs.

Note your commits do not follow the contribution guidance and are not signed off for DCO so those will need fixing: https://github.com/fluent/fluent-bit/blob/master/CONTRIBUTING.md#commit-changes

@patrick-stephens
Copy link
Contributor

@cosmo0920 may have some input here.

@alt-dima could you update your commit messages and sign them off? I'm reluctant to kick off the CI without it as we'll just have to do it again when the commits are updated.

@alt-dima
Copy link
Author

To fix an issue
[error] [flb_kafka] cannot configure 'compression.type' property = removed from configuration, probably gzip support was missing when build

I added to the dockerfile.windows:

# Install ZLIB: https://github.com/horta/zlib.install
ADD https://github.com/alt-dima/zlib.install/raw/master/install.bat /local/install_zlib.bat
RUN /local/install_zlib.bat
RUN Copy-Item -Path '/Program Files/zlib/bin/zlib.dll' -Destination /fluent-bit/bin/;

But I'm not sure it is a good choice.

@alt-dima alt-dima changed the title Fix windows docker build and enable out_kafka windows: build docker image with out_kafka and gzip Oct 17, 2022
@alt-dima alt-dima temporarily deployed to pr October 17, 2022 15:40 Inactive
@alt-dima
Copy link
Author

Nice! Finally, all the problems were solved, will test some days.

Fluent Bit v2.0.0
* Copyright (C) 2015-2022 The Fluent Bit Authors
* Fluent Bit is a CNCF sub-project under the umbrella of Fluentd
* https://fluentbit.io

[2022/10/17 15:40:45] [ info] [fluent bit] version=2.0.0, commit=, pid=3836
[2022/10/17 15:40:45] [ info] [storage] ver=1.3.0, type=memory, sync=normal, checksum=off, max_chunks_up=128
[2022/10/17 15:40:45] [ info] [cmetrics] version=0.5.2
[2022/10/17 15:40:45] [ info] [input:tail:tail.0] initializing
[2022/10/17 15:40:45] [ info] [input:tail:tail.0] storage_strategy='memory' (memory only)
[2022/10/17 15:40:45] [ info] [input:tail:tail.0] multiline core started
[2022/10/17 15:40:45] [ info] [filter:kubernetes:kubernetes.0] https=1 host=kubernetes.default.svc.cluster.local port=443
[2022/10/17 15:40:45] [ info] [filter:kubernetes:kubernetes.0]  token updated
[2022/10/17 15:40:45] [ info] [filter:kubernetes:kubernetes.0] local POD info OK
[2022/10/17 15:40:45] [ info] [filter:kubernetes:kubernetes.0] host: kubernetes.default.svc.cluster.local Wait 30 secs until DNS starts up (1/6)
[2022/10/17 15:41:15] [ info] [filter:kubernetes:kubernetes.0] testing connectivity with API server...
[2022/10/17 15:41:15] [ info] [filter:kubernetes:kubernetes.0] connectivity OK
[2022/10/17 15:41:15] [ info] [input:emitter:emitter_for_rewrite_tag.4] initializing
[2022/10/17 15:41:15] [ info] [input:emitter:emitter_for_rewrite_tag.4] storage_strategy='memory' (memory only)
[2022/10/17 15:41:15] [ info] [output:kafka:kafka.0] brokers='b-1.staging1konaws.com:9092' topics='app-logs'
[2022/10/17 15:41:15] [ info] [output:kafka:kafka.1] brokers='b-1.stagi.amazonaws.com:9092' topics='app-metrics'
[2022/10/17 15:41:15] [ info] [http_server] listen iface=0.0.0.0 tcp_port=2020
[2022/10/17 15:41:15] [ info] [sp] stream processor started

@alt-dima
Copy link
Author

Build for 64bit was fine, but for 32bit failed, probably because of

#pragma comment(lib, "libcrypto64MT.lib")
#pragma comment(lib, "libssl64MT.lib")

@alt-dima
Copy link
Author

alt-dima commented Oct 18, 2022

I have a problem with in_tail. Seems like rotation handling working correctly, but error appears.
Moved to PR #6230

Dmitrii Altukhov added 10 commits October 18, 2022 11:27
Signed-off-by: alt-dima <[email protected]>
Signed-off-by: alt-dima <[email protected]>
Signed-off-by: alt-dima <[email protected]>
Signed-off-by: alt-dima <[email protected]>
fix
Signed-off-by: alt-dima <[email protected]>
Signed-off-by: alt-dima <[email protected]>
Signed-off-by: alt-dima <[email protected]>
Signed-off-by: alt-dima <[email protected]>
Signed-off-by: alt-dima <[email protected]>
Signed-off-by: alt-dima <[email protected]>
Signed-off-by: alt-dima <[email protected]>
@@ -75,7 +75,7 @@ if(FLB_WINDOWS_DEFAULTS)
set(FLB_OUT_LIB Yes)
set(FLB_OUT_NULL Yes)
set(FLB_OUT_FLOWCOUNTER Yes)
set(FLB_OUT_KAFKA No)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is just for my curiosity.
Should we disable for out_kafka plugin building on Windows and specify enabling parameter on configure at Windows container building?

This is because to build out_kafka plugin on Windows, we have to introduce dependent zlib library for our CI tasks.

Copy link
Contributor

Choose a reason for hiding this comment

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

Did we do this anyway now @cosmo0920? Ah no, I think that was just for our commercial offering...

Comment on lines 42 to 43
#pragma comment(lib, "libcrypto64MT.lib")
#pragma comment(lib, "libssl64MT.lib")
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you determine whether the using 64MT or 32MT suffixed libraries with CMakeLists.txt?
This change should be working only for 64bit of Windows.

@alt-dima alt-dima temporarily deployed to pr October 31, 2022 12:07 Inactive
@@ -38,6 +38,11 @@ RUN Start-Process /local/vc_redist.x64.exe -ArgumentList '/install', '/quiet', '
Copy-Item -Path /Windows/System32/vccorlib140.dll -Destination /fluent-bit/bin/; `
Copy-Item -Path /Windows/System32/vcruntime140.dll -Destination /fluent-bit/bin/;

# Install ZLIB: https://github.com/horta/zlib.install
ADD https://github.com/alt-dima/zlib.install/raw/master/install.bat /local/install_zlib.bat
Copy link
Contributor

@patrick-stephens patrick-stephens Oct 31, 2022

Choose a reason for hiding this comment

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

We probably should not depend on master of another repo we have no control over - potentially this is updated and breaks the build best case (worst case it's a malware attack vector). At the very least this makes a build non-reproducible.

We should either put the commands inline in the Dockerfile or move the script into this repo as part of the PR - then it can be versioned alongside.

@github-actions
Copy link
Contributor

This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions bot added the Stale label Jan 30, 2023
@github-actions github-actions bot removed the Stale label Mar 1, 2023
@github-actions
Copy link
Contributor

This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions bot added the Stale label May 31, 2023
@github-actions github-actions bot removed the Stale label Aug 6, 2023
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.

3 participants