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

Cover case when config file is in different location than binary #342

Merged
merged 1 commit into from
Jan 25, 2024

Conversation

r-savcenko
Copy link
Contributor

@r-savcenko r-savcenko commented Jan 25, 2024

Check if result of exec contains "error". This covers cases when filebeat config is not in the same directory and result of the exec is not empty, but rather Loading config file error: Failed to read /usr/bin/filebeat.yml: open /usr/bin/filebeat.yml: no such file or directory. Exiting. which further cannot be parsed as a valid version.

The case:

# systemctl status filebeat.service
● filebeat.service - filebeat
   Loaded: loaded (/usr/lib/systemd/system/filebeat.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2023-04-05 13:18:33 CEST; 9 months 20 days ago
     Docs: https://www.elastic.co/guide/en/beats/filebeat/current/index.html
 Main PID: 751 (filebeat)
   CGroup: /system.slice/filebeat.service
           └─751 /usr/bin/filebeat -c /etc/filebeat/filebeat.yml

The result without fix:

# facter -p filebeat_version --trace
2024-01-25 06:03:37.224036 ERROR puppetlabs.facter - error while resolving custom fact "filebeat_version": undefined method `[]' for nil:NilClass
backtrace:
/opt/puppetlabs/puppet/cache/lib/facter/filebeat_version.rb:34:in `block (2 levels) in <top (required)>'

The result with fix:

# facter -p filebeat_version --trace
1.3.1

Check if result of exec contains "error". This covers cases when filebeat config is not in the same directory
@pcfens pcfens merged commit 8bdc573 into pcfens:master Jan 25, 2024
@r-savcenko r-savcenko deleted the patch-1 branch January 26, 2024 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants