elastic / elastic/logstash

`--config.test_and_exit` creates files

Open
#6,486 4 comments 0 reactions 1 assignee Claimed by @jsvd View on GitHub
bug
Dominant language
Java
Stars
14.9k
Forks
3.5k
Avg merge
19h 14m
Merged PRs (30d)
63

Description

We are using [elastic/puppet-logstash](https://github.com/elastic/puppet-logstash) to install and configure Logstash. After Puppet runs, we then run [serverspec](http://serverspec.org/) tests to verify that the system is in a working state. The following snippet shows a subset of our serverspec tests for Logstash:

```
describe 'logstash' do
context service('logstash') do
it { should be_enabled }
it { should be_running }
end

context command('/usr/share/logstash/bin/logstash --config.test_and_exit --path.settings /etc/logstash') do
its(:exit_status) { should eq 0 }
end
end
```

These tests run as `root`, and I just spent a non-trivial amount of time figuring out how Logstash was sometimes failing to start. Basically, if this serverspec tests is executed before the `logstash` service has created Logstash log files, then the config test will create these files instead. Because we are running the config test as `root`, some Logstash files end up being created with the wrong ownership and subsequently Logstash fails to start.

I was able to workaround this issue by changing our serverspec tests to:

```
describe 'logstash' do
context service('logstash') do
it { should be_enabled }
it { should be_running }
end

context command('sudo -u logstash -- /usr/share/logstash/bin/logstash --config.test_and_exit --path.settings /etc/logstash') do
its(:exit_status) { should eq 0 }
end
end
```

I think, however, that Logstash shouldn't create these output files when run with the `--config.test_and_exit` flag.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.