fullstorydev / hauser

Service for moving your Fullstory export files to a data warehouse
MIT License
49 stars 23 forks source link

Docker setup - export works with mount volume but gives a permission denied error without it #111

Closed atati-cs closed 3 years ago

atati-cs commented 3 years ago

I've built a docker image (hauser:0.1) using the Docker file in the repository.

The two changes that I have in the Dockerfile are

  1. Copying the config.toml file to the image and
  2. A change in the ENTRYPOINT directive as follows
COPY config.toml /
ENTRYPOINT ["/bin/hauser", "-c", "/config.toml"]

When I do a docker run, as follows, I get a permission denied error

# docker run hauser:0.1
2021/07/29 16:12:23 Creating export for 2021-06-15 00:00:00 +0000 UTC to 2021-06-16 00:00:00 +0000 UTC
2021/07/29 16:12:24 Export progress: 0%
2021/07/29 16:12:29 Export progress: 100%
2021/07/29 16:12:29 Fetching export for operation id U0VB<REDACTED>dm1V
2021/07/29 16:12:29 Failed to create tmp csv file: open 1623715200.csv: permission denied
2021/07/29 16:12:29 failed to process exports: open 1623715200.csv: permission denied
2021/07/29 16:12:29 Pausing; will retry operation in 30s

After some trial and error, I made an assumption that the TmpDir specified in the config.toml file may be referring to the host's directory instead of the container's directory. So, I created a "/tmp/hauser_data" directory on the host and tried the docker run with a mount volume as follows and it worked

# docker run -v /tmp/hauser_data:/tmp hauser:0.1
2021/07/29 17:28:04 Creating export for 2021-06-15 00:00:00 +0000 UTC to 2021-06-16 00:00:00 +0000 UTC
2021/07/29 17:28:05 Export progress: 0%
2021/07/29 17:28:10 Export progress: 100%
2021/07/29 17:28:10 Fetching export for operation id U0VB<REDACTED>TXZV
2021/07/29 17:28:10 Creating export for 2021-06-16 00:00:00 +0000 UTC to 2021-06-17 00:00:00 +0000 UTC
2021/07/29 17:28:10 Export progress: 0%
2021/07/29 17:28:15 Export progress: 100%
2021/07/29 17:28:15 Fetching export for operation id U0VB<REDACTED>UzlB
2021/07/29 17:28:16 Creating export for 2021-06-17 00:00:00 +0000 UTC to 2021-06-18 00:00:00 +0000 UTC
2021/07/29 17:28:16 Export progress: 0%
2021/07/29 17:28:21 Export progress: 100%

I have a couple of questions based on this:

  1. Is the Docker container actually trying to write the temporary files to the host?
  2. a. If yes, is there a way I can make it write to the container instead of the host during the docker run b. If no, can anyone help with the setup option that will avoid the permission denied error
camphillips22 commented 3 years ago

Hey @atati-cs, sorry for the long wait!

I've actually got a PR up to address part of this issue: #107. However, this solution will only work if your TmpDir is unset, starts with /hauser, or does not start with a slash (e.g. TmpDir = "tmp").

If you would like to save the tmp files to a different location, you can mount a folder as you demonstrated.

There is a bit of tension here since the docker container is supposed to be as lightweight as possible (essentially just a single binary), but the hauser process may require saving some fairly large files temporarily. I believe the default size of docker containers is 10GB, so if your export files are large enough, this could also be a problem when simply writing to the container disk. If you ever run into this issue, I would suggest either shortening the ExportDuration in the config file, or mounting a directory from the host. Changing the duration is definitely the simplest method.

atati-cs commented 3 years ago

@camphillips22 thank you for your response and the clarification. I realize one additional change I have made in the config.toml file which may have been the reason for the permission denied error that I was getting. I've used the "/tmp" as the "TmpDir" with the additional slash ("/") in the front. Your comment about "does not start with a slash" above made me look at my configuration again. My issue is resolved now!