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

in_calyptia_fleet: rewrite error handling code for get_calyptia_file to fix warnings. #8271

Merged
merged 1 commit into from
Dec 18, 2023

Conversation

pwhelan
Copy link
Contributor

@pwhelan pwhelan commented Dec 11, 2023

Summary

The following warning appears when using clang 15.0.0:

/Users/pwhelan/Code/fluent-bit/plugins/in_calyptia_fleet/in_calyptia_fleet.c:1002:9: warning: variable 'fname' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
    if (ret < 0) {
        ^~~~~~~
/Users/pwhelan/Code/fluent-bit/plugins/in_calyptia_fleet/in_calyptia_fleet.c:1053:21: note: uninitialized use occurs here
    flb_sds_destroy(fname);
                    ^~~~~
/Users/pwhelan/Code/fluent-bit/plugins/in_calyptia_fleet/in_calyptia_fleet.c:1002:5: note: remove the 'if' if its condition is always false
    if (ret < 0) {
    ^~~~~~~~~~~~~~
/Users/pwhelan/Code/fluent-bit/plugins/in_calyptia_fleet/in_calyptia_fleet.c:987:20: note: initialize the variable 'fname' to silence this warning
    flb_sds_t fname;

This PR fixes the code to both eliminate this warning and to make it more legible.

[ 81%] Building C object plugins/in_calyptia_fleet/CMakeFiles/flb-plugin-in_calyptia_fleet.dir/in_calyptia_fleet.c.o
[ 81%] Linking C static library ../../library/libflb-plugin-in_calyptia_fleet.a

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.

@pwhelan
Copy link
Contributor Author

pwhelan commented Dec 12, 2023

Here is a sample run with the patch applied:

./build/bin/fluent-bit -c fleet.conf
Fluent Bit v2.2.1
* Copyright (C) 2015-2023 The Fluent Bit Authors
* Fluent Bit is a CNCF sub-project under the umbrella of Fluentd
* https://fluentbit.io

[2023/12/11 20:59:04] [ info] [fluent bit] version=2.2.1, commit=469652f625, pid=48075
[2023/12/11 20:59:04] [ info] [custom:calyptia:calyptia.0] custom initialized!
[2023/12/11 20:59:04] [ info] [storage] ver=1.5.1, type=memory, sync=normal, checksum=off, max_chunks_up=128
[2023/12/11 20:59:04] [ info] [cmetrics] version=0.6.5
[2023/12/11 20:59:04] [ info] [ctraces ] version=0.3.1
[2023/12/11 20:59:04] [ info] [input:fluentbit_metrics:fluentbit_metrics.0] initializing
[2023/12/11 20:59:04] [ info] [input:fluentbit_metrics:fluentbit_metrics.0] storage_strategy='memory' (memory only)
[2023/12/11 20:59:04] [ info] [input:calyptia_fleet:calyptia_fleet.1] initializing
[2023/12/11 20:59:04] [ info] [input:calyptia_fleet:calyptia_fleet.1] storage_strategy='memory' (memory only)
[2023/12/11 20:59:04] [ info] [input:calyptia_fleet:calyptia_fleet.1] initializing calyptia fleet input.
[2023/12/11 20:59:04] [ warn] [read_glob] glob: [/tmp/calyptia-fleet/99d70f0171de7aec9b8ae68b1f6e32b7dd65763b0b73dd603ed95a112b0bf8ee/fleet-script-file/*.conf] no match
[2023/12/11 20:59:04] [error] [input:calyptia_fleet:calyptia_fleet.1] unable to read fleet directory for conf files: /tmp/calyptia-fleet/99d70f0171de7aec9b8ae68b1f6e32b7dd65763b0b73dd603ed95a112b0bf8ee/fleet-script-file/*.conf
[2023/12/11 20:59:04] [ warn] [input:calyptia_fleet:calyptia_fleet.1] unable to find latest configuration file
[2023/12/11 20:59:04] [ info] [sp] stream processor started
[2023/12/11 20:59:20] [ info] [input:calyptia_fleet:calyptia_fleet.1] loading configuration from /tmp/calyptia-fleet/99d70f0171de7aec9b8ae68b1f6e32b7dd65763b0b73dd603ed95a112b0bf8ee/fleet-script-file/new.conf.
[2023/12/11 20:59:20] [ info] [input:calyptia_fleet:calyptia_fleet.1] changing to config dir: /tmp/calyptia-fleet/99d70f0171de7aec9b8ae68b1f6e32b7dd65763b0b73dd603ed95a112b0bf8ee/fleet-script-file/1700004854
[2023/12/11 20:59:20] [ info] [input:calyptia_fleet:calyptia_fleet.1] changing to config dir: /tmp/calyptia-fleet/99d70f0171de7aec9b8ae68b1f6e32b7dd65763b0b73dd603ed95a112b0bf8ee/fleet-script-file/1700004854
[2023/12/11 20:59:25] [engine] caught signal (SIGHUP)
[2023/12/11 20:59:25] [ info] reloading instance pid=48075 tid=0x7ffff6df7ac0
[2023/12/11 20:59:25] [ info] [reload] stop everything of the old context
[2023/12/11 20:59:25] [ warn] [engine] service will shutdown when all remaining tasks are flushed
[2023/12/11 20:59:25] [ info] [input] pausing fluentbit_metrics.0
[2023/12/11 20:59:25] [ info] [input] pausing calyptia_fleet.1
[2023/12/11 20:59:25] [ info] [engine] service has stopped (0 pending tasks)
[2023/12/11 20:59:25] [ info] [input] pausing fluentbit_metrics.0
[2023/12/11 20:59:25] [ info] [input] pausing calyptia_fleet.1
[2023/12/11 20:59:25] [ info] [reload] start everything
[2023/12/11 20:59:25] [ info] [fluent bit] version=2.2.1, commit=469652f625, pid=48075
[2023/12/11 20:59:25] [ info] [custom:calyptia:calyptia.0] custom initialized!
[2023/12/11 20:59:25] [ info] [storage] ver=1.5.1, type=memory, sync=normal, checksum=off, max_chunks_up=128
[2023/12/11 20:59:25] [ info] [cmetrics] version=0.6.5
[2023/12/11 20:59:25] [ info] [ctraces ] version=0.3.1
[2023/12/11 20:59:25] [ info] [input:dummy:dummy.0] initializing
[2023/12/11 20:59:25] [ info] [input:dummy:dummy.0] storage_strategy='memory' (memory only)
[2023/12/11 20:59:25] [ info] [input:fluentbit_metrics:fluentbit_metrics.1] initializing
[2023/12/11 20:59:25] [ info] [input:fluentbit_metrics:fluentbit_metrics.1] storage_strategy='memory' (memory only)
[2023/12/11 20:59:25] [ info] [input:calyptia_fleet:calyptia_fleet.2] initializing
[2023/12/11 20:59:25] [ info] [input:calyptia_fleet:calyptia_fleet.2] storage_strategy='memory' (memory only)
[2023/12/11 20:59:25] [ info] [input:calyptia_fleet:calyptia_fleet.2] initializing calyptia fleet input.
[2023/12/11 20:59:25] [ info] [output:stdout:stdout.0] worker #0 started
[2023/12/11 20:59:25] [ info] [output:calyptia:calyptia.1] connected to Calyptia, agent_id='3367b469-eb0d-42e3-8043-976222296359'
[2023/12/11 20:59:25] [ info] [sp] stream processor started
[0] dummy: [[1702339166.539031648, {}], {"powered_by"=>"calyptia", "message"=>"unscripted #13"}]
[0] dummy: [[1702339167.539034336, {}], {"powered_by"=>"calyptia", "message"=>"unscripted #13"}]
[0] dummy: [[1702339168.539040635, {}], {"powered_by"=>"calyptia", "message"=>"unscripted #13"}]
[0] dummy: [[1702339169.539036162, {}], {"powered_by"=>"calyptia", "message"=>"unscripted #13"}]
[0] dummy: [[1702339170.539286517, {}], {"powered_by"=>"calyptia", "message"=>"unscripted #13"}]
[0] dummy: [[1702339171.539036545, {}], {"powered_by"=>"calyptia", "message"=>"unscripted #13"}]
^C[2023/12/11 20:59:32] [engine] caught signal (SIGINT)
[0] dummy: [[1702339172.539036042, {}], {"powered_by"=>"calyptia", "message"=>"unscripted #13"}]
[2023/12/11 20:59:32] [ warn] [engine] service will shutdown in max 5 seconds
[2023/12/11 20:59:32] [ info] [input] pausing dummy.0
[2023/12/11 20:59:32] [ info] [input] pausing fluentbit_metrics.1
[2023/12/11 20:59:32] [ info] [input] pausing calyptia_fleet.2
[2023/12/11 20:59:33] [ info] [engine] service has stopped (0 pending tasks)
[2023/12/11 20:59:33] [ info] [input] pausing dummy.0
[2023/12/11 20:59:33] [ info] [input] pausing fluentbit_metrics.1
[2023/12/11 20:59:33] [ info] [input] pausing calyptia_fleet.2
[2023/12/11 20:59:33] [ info] [output:stdout:stdout.0] thread worker #0 stopping...
[2023/12/11 20:59:33] [ info] [output:stdout:stdout.0] thread worker #0 stopped

@edsiper
Copy link
Member

edsiper commented Dec 12, 2023

@pwhelan please fix the commit, it needs to start with in_calyptia_fleet: ...

@pwhelan pwhelan force-pushed the pwhelan-fleet-fix-warnings branch from 1c0438d to 3e3122a Compare December 12, 2023 18:17
@pwhelan pwhelan changed the title fleet: rewrite error handling code for get_calyptia_file to fix warnings. in_calyptia_fleet: rewrite error handling code for get_calyptia_file to fix warnings. Dec 12, 2023
@edsiper edsiper merged commit 220e1ba into master Dec 18, 2023
45 checks passed
@edsiper edsiper deleted the pwhelan-fleet-fix-warnings branch December 18, 2023 16:54
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.

2 participants