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

kapacitor config doesn't work without prevoius config in beta #628

Closed
theist opened this issue Jun 9, 2016 · 4 comments
Closed

kapacitor config doesn't work without prevoius config in beta #628

theist opened this issue Jun 9, 2016 · 4 comments

Comments

@theist
Copy link

theist commented Jun 9, 2016

OS ubuntu 16.04 64 bits
kapacitor kapacitor_1.0.0~beta1_amd64 deb package

steps to reproduce:

wget https://dl.influxdata.com/kapacitor/releases/kapacitor_1.0.0~beta1_amd64.de
dpkg -i kapacitor_1.0.0~beta1_amd64.deb
mv /etc/kapacitor/kapacitor.conf /etc/kapacitor/kapacitor.conf.dpkg-old
kapacitord config > kapacitor.generated.conf

config: must configure valid data dir. To generate a valid configuration file run `kapacitord config > kapacitor.generated.conf`.

So kapacitor can not generate a config if there's no previous config. I expected that kapacitor was able to generate a config regardless if there's a previous config or not, like the "solve" message suggest

@bbczeuz
Copy link
Contributor

bbczeuz commented Jun 9, 2016

Try renaming your current config (in /etc/kapacitor/) and then regenerating it.

@nathanielc
Copy link
Contributor

nathanielc commented Jun 9, 2016

@theist You are correct that the existence of a config should not matter when generating a new default config.

I copy pasted your steps in a fresh ubuntu install and was able to successfully create a default config. Could something else be going on?

@theist
Copy link
Author

theist commented Jun 9, 2016

Yeah! @nathanielc You are right ... moving / creating files I created the kapacitor.conf file empty. It seems that the unix stdout redirection creates the file before kapacitor reads it an it fails when there's an empty file and not if there's no file, and this can happen or not depends on events speed.

look (inside a docker container, ubuntu 14.04, kapacitor beta 1.0.0)

root@1ce158a0a963:/etc/kapacitor# ls
kapacitor.conf.dpkg-old
root@1ce158a0a963:/etc/kapacitor# ls -la
total 20
drwxr-xr-x  2 root root  4096 Jun  9 21:11 .
drwxr-xr-x 44 root root  4096 Jun  9 21:07 ..
-rw-rw-r--  1 root root 11204 Jun  6 23:15 kapacitor.conf.dpkg-old
root@1ce158a0a963:/etc/kapacitor# kapacitord config | wc -l
159
# works as expected

root@1ce158a0a963:/etc/kapacitor# kapacitord config > kapacitor.conf          
config: must configure valid data dir. To generate a valid configuration file run `kapacitord config > kapacitor.generated.conf`.
root@1ce158a0a963:/etc/kapacitor# ls -la
total 20
drwxr-xr-x  2 root root  4096 Jun  9 21:18 .
drwxr-xr-x 44 root root  4096 Jun  9 21:07 ..
-rw-r--r--  1 root root     0 Jun  9 21:18 kapacitor.conf   # the file is here but empty, bash redirection magic
-rw-rw-r--  1 root root 11204 Jun  6 23:15 kapacitor.conf.dpkg-old

So it seems that kapacitord config can't create config if there's and empy kapacitor.conf file. And bash magic about pipes can cause a sort of race condition.

Now maybe it can be considered a feature :) sorry for the noise

@nathanielc
Copy link
Contributor

@theist You are correct bash will truncate a file before output is redirected there. So specifically running kapacitord config > /etc/kapacitor/kapacitor.conf will cause the error since the config is truncated first. Which is confusing.

I think we should change the kapacitord config command to behave like the kapacitord run command where the config is either explicitly set or defaults are used. Instead of the current behavior where it searches for an existing config. PR coming

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

No branches or pull requests

3 participants