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

Fix permissions of logs directory #18

Closed
wants to merge 3 commits into from

Conversation

tristan0x
Copy link
Contributor

When logs directory /usr/share/elasticsearch/logs is mount as data volume,
then it is owned by root and elasticsearch was not allowed to write logs.

This PR modifies the Dockerfile entrypoint to properly chown the logs directory if available.

Tristan Carel added 3 commits April 10, 2015 09:53
When logs directory /usr/share/elasticsearch/logs is mount as data volume,
then it is owned by root and elasticsearch was not allowed to write logs.
@daghack
Copy link
Contributor

daghack commented Apr 10, 2015

grumpycat

Moghedrin punts explanation to @yosifkit

@yosifkit
Copy link
Member

Following the docker way, we log to stdout and stderr (logging.yml). Docker 1.6 now has --log-driver in docker run which can facilitate things like syslog.

Also, @Moghedrin was grumpy about the whitespace changes. #holywars (we use tabs)

@daghack
Copy link
Contributor

daghack commented Apr 10, 2015

holywar

@tristan0x
Copy link
Contributor Author

Sorry guys, I can understand the religion war between spaces and tabs which has occured for decades. But I don't understand why logging to files is not a good pattern.

Why stdout and stderr are not enough?

My Elasticsearch logging.yml settings create several files per index, among them files dedicated to slow queries, shard replication, and so on. Logs are dispatched in the first place, and it helps a log their processing. This dispatched is application specific, and should be specified in the container, not in the Docker host syslog config.

Why using files for logs?

Once a log is emitted, the application does not have to worry wether the log will be processed or no. The log is safe, its processing asynchronous, meaning that there is no performance degradation of the application.

Why using a volume for logs?

Logs processing can be handled by other containers. For instance I can use a rsyslog container reading logs of application containers hosted on the same registry. Rsyslog then pushes logs to a logstash container, so that I can use a Kibana container to monitor my applications logs.

Please explain me why this is not a good pattern. If you can share some resources that can enlight me, please do.

@md5
Copy link
Contributor

md5 commented Apr 11, 2015 via email

@tianon
Copy link
Member

tianon commented Apr 11, 2015 via email

@tristan0x tristan0x closed this Apr 13, 2015
@md5 md5 mentioned this pull request Apr 16, 2015
@bobrik
Copy link

bobrik commented Apr 19, 2015

Elasticsearch has default logging location set to /usr/share/elasticsearch/logs. There is no need to guess this location.

Changing permissions won't break existing containers and would enable logs on disk without any extending required.

@Garito
Copy link

Garito commented Apr 22, 2015

For those who said no as full response:

How it is supossed to consume those logs?

I understand that stdout is the docker's way to send logs to the user because is the basic way to comunicate with the user not because it has to be religion or because is better or, at least, no if you don't point out how to deal with this

Logs aren't something for weird people is THE NORM everyone uses them in a way or another so seems to me that an image considered official has to provide some solution for that

@yosifkit
Copy link
Member

Given that currently most official images only log to stdout/stderr it is unlikely to change, but not impossible, where we default the logs. That said, we should be able to at least document how a user can provide their own config for elasticsearch and output those logs to a mounted volume or data container.

@tristan0x
Copy link
Contributor Author

@yosifkit 👍 Couldn't agree more.

But this PR is still required to do this the most standard way though. It properly chown the default elasticsearch log directory if present (more likely because it has been mount).
I offer my help to create the according PR on docker-library/docs...

@tristan0x tristan0x reopened this Apr 22, 2015
@Garito
Copy link

Garito commented Apr 22, 2015

Seems good to me but, sorry, don't would like to offend no one, ok, but let me do a joke:

seems to me a little Sheldon Cooper to put a for loop for 2 folders: what you safe with the for, giving the fact that there are only 2 folders and is so difficult that need more, in terms of lines of code you expend in make the AST bigger

In more serious terms: I see the point but I see this as an over optimization since there is and will be only two folders

But the pattern seems to me good enought
+1

Thanks

@tristan0x
Copy link
Contributor Author

@Garito very funny :)

I don't really mind, but I think the for loop is the exact implementation of the comment above.

@tianon
Copy link
Member

tianon commented May 19, 2015

I'm still confused because the only way I see to actually use this is by supplying custom configuration that tells elasticsearch to log here (since we overwrite the default configuration with one that states logs should go to stdout). Can you provide an example of how this would be intended to be used?

@bobrik
Copy link

bobrik commented May 19, 2015

"Custom" configuration is the default one, it comes with elasticsearch itself:

https://github.com/elastic/elasticsearch/blob/master/config/logging.yml

Paths there are relative to path.logs, it defaults to /usr/share/elasticsearch/logs.

I bind-mount logging.yml that comes with elasticsearch to the container and expect it to work.

@j0hnsmith
Copy link

This is a tiny change (chmoding the 'default' elasticsearch logs dir, not necessarily this pull request) that won't change the default behaviour or have any detrimental effect to the way containers based on this image work (they'll still log to stdout, the docker way).

People want to use official images rather than maintain derived ones, companies moving to docker may be comfortable with using official images but not comfortable with maintaining their own. This refusal seems overzealous, to say the least.

@mi-hol
Copy link

mi-hol commented Dec 14, 2016

@yosifkit would it make sense to close this?

@tianon
Copy link
Member

tianon commented Dec 19, 2016

@j0hnsmith makes a good point that this logs directory does exist by default, so supporting it is sane enough I suppose; I'll work up a replacement PR to carry this change 👍

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.

None yet

9 participants