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

generated config file should have canonical paths by default, not ~ #6392

Closed
beckettsean opened this issue Apr 15, 2016 · 9 comments
Closed

Comments

@beckettsean
Copy link
Contributor

Bug report

System info: [Include InfluxDB version, operating system name, and other relevant details]
InfluxDB 0.12, any non-OS X system

According to @rkuchan in influxdata/docs.influxdata.com-ARCHIVE#390 (comment), the generated config file has OS X specific paths for the meta, data, and wal directoies.

Expected behavior: [What you expected to happen]

I think we should default to Linux paths, not OS X.

@beckettsean
Copy link
Contributor Author

@rossmcdonald am I missing something?

@gunnaraasen
Copy link
Member

gunnaraasen commented Apr 15, 2016

Looks like it's not OS X specific. The data directories are set to the user's directory.

https://github.com/influxdata/influxdb/blob/master/cmd/influxd/run/config.go#L100

Should be pretty easy to set the directory name as a build flag and add support for the correct data directories names per distribution to the build script.

@rossmcdonald
Copy link
Contributor

Yep, the generated paths default to putting everything under ~/.influxdb, so if you run it as root you get /root/.influxdb. Having a build flag that sets which directories are used would be very useful, though.

@beckettsean beckettsean changed the title generated config file should have Linux paths by default generated config file should have canonical paths by default, not ~ Apr 15, 2016
@beckettsean
Copy link
Contributor Author

Confirmed it's using ~, not anything OS X specific. I do think we should use /var/lib if we can, since that's the canonical install location.

@beckettsean
Copy link
Contributor Author

Alternately, can we put something in the config file or the upgrade instructions that gives a one-liner for the conversion? Something like sed /$HOMEDUR/\/var\/lib/gi or whatever is syntactically correct.

@jsternberg
Copy link
Contributor

The primary reason for this is so that it's possible to run the binary easily when run as non-root. This is essential for us as developers as we don't want to have to generate a config when we're testing locally or run the application as root on our development machines.

It's possible for us to detect when the user is root and change the config locations, but it's inadvisable to run the server as root anyway and we would then have to hard code the username. It's much easier to just have the package include a config with the appropriate paths that gets run or have them set by environment variables as part of the init script.

If we're concerned about the binary writing to /root/.influxdb, we can also have a check when starting the server and have it so it won't start when the user is root by default. Then you just add a new command line option to turn off that feature. It prevents people from stupidly starting the binary as root, but still allows them to shoot themselves in the foot if they're really intent on doing that.

@beckettsean
Copy link
Contributor Author

My concern is not really about /root but that the package is configured by default for the non-production use case. I don't think that makes sense. Why optimize for the developer use case when we want people to find it easy to use in production? Is there not a way to handle the developer use case with environment variables, perhaps? Asking every sysadmin to alter the config file every upgrade for the convenience of the developers seems selfish, to me.

@jwilder
Copy link
Contributor

jwilder commented Apr 19, 2016

You can use env vars to generate a config with different defaults:

INFLUXDB_DATA_DIR=/var/lib/influxdb/data INFLUXDB_DATA_WAL_DIR=/var/lib/influxdb/wal INFLUXDB_META_DIR=/var/lib/influxdb/meta influxd config > config.toml
...

[meta]
  dir = "/var/lib/influxdb/meta"
  retention-autocreate = true
  logging-enabled = true
  pprof-enabled = false
  lease-duration = "1m0s"

[data]
  dir = "/var/lib/influxdb/data"
  engine = "tsm1"
  wal-dir = "/var/lib/influxdb/wal"
  wal-logging-enabled = true
  query-log-enabled = true
  cache-max-memory-size = 524288000
  cache-snapshot-memory-size = 26214400
  cache-snapshot-write-cold-duration = "1h0m0s"
  compact-full-write-cold-duration = "24h0m0s"
  max-points-per-block = 0
  data-logging-enabled = true

...

jsternberg added a commit that referenced this issue Apr 22, 2016
The config path previously could only be specified through the command
line options. This made it very difficult to set a default config path
without using any option.

Now the environment variable can be set so the default configuration
path is set to a specific place, but can be overwritten using the
command line option.

The primary purpose of this is so the Docker container can have a
default configuration file, but not have to parse the command line
options to figure out if a different configuration file has been
specified while still allowing the user to only type `influxd` and have
the program start correctly.

This might also help #6392 as it would allow a default configuration
location to be included with the package by setting an environment
variable.

A default search path is also provided now with checking the following
paths for a config file when none is specified:

* `~/.influxdb/influxdb.conf`
* `/etc/influxdb/influxdb.conf`
jsternberg added a commit that referenced this issue Apr 22, 2016
The config path previously could only be specified through the command
line options. This made it very difficult to set a default config path
without using any option.

Now the environment variable can be set so the default configuration
path is set to a specific place, but can be overwritten using the
command line option.

The primary purpose of this is so the Docker container can have a
default configuration file, but not have to parse the command line
options to figure out if a different configuration file has been
specified while still allowing the user to only type `influxd` and have
the program start correctly.

This might also help #6392 as it would allow a default configuration
location to be included with the package by setting an environment
variable.

A default search path is also provided now with checking the following
paths for a config file when none is specified:

* `~/.influxdb/influxdb.conf`
* `/etc/influxdb/influxdb.conf`

The config command has also been modified to read this config file
before outputting a sample config.
@jwilder
Copy link
Contributor

jwilder commented Nov 17, 2016

Closing this since the config file installed via packages have the correct paths and you should not be generating a config when using the packages.

@jwilder jwilder closed this as completed Nov 17, 2016
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

5 participants