question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Default generated logger config causes "Permission denied: '/homeserver.log'" for non-root containers

See original GitHub issue

Description

Using generate to create config files with the Docker image sets the value of handlers.file.filename inside the *.log.config file to /homeserver.log, causing the following error when running the container as non-root:

PermissionError: [Errno 13] Permission denied: '/homeserver.log'

Changing it to /data/homeserver.log fixes the issue since the synapse user has write access to that folder.

Unfortunately it’s not enough to disable the file log handler. Even when disabled an empty log file is initially created.

Steps to reproduce

  • Create minimal config files with generate
  • Run container in non-root mode

Version information

If not matrix.org:

  • Version: v1.33.1

  • Install method: Docker Image

  • Platform: Kubernetes

Cause

The issue lies within how the log config is generated (https://github.com/matrix-org/synapse/blob/develop/synapse/config/logger.py#L171-L180):

    def generate_files(self, config, config_dir_path):
        log_config = config.get("log_config")
        if log_config and not os.path.exists(log_config):
            log_file = self.abspath("homeserver.log")
            print(
                "Generating log config file %s which will log to %s"
                % (log_config, log_file)
            )
            with open(log_config, "w") as log_config_file:
                log_config_file.write(DEFAULT_LOG_CONFIG.substitute(log_file=log_file))

which calls:

@staticmethod
    def abspath(file_path):
        return os.path.abspath(file_path) if file_path else file_path

Since the container runs start.py in /, the above resolves to /homeserver.log

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:6
  • Comments:22 (7 by maintainers)

github_iconTop GitHub Comments

4reactions
jakobkmarcommented, May 19, 2021

This currently breaks the installation of anyone trying to install Synapse the first time using Docker, could you please change the default to /data/homeserver.log until you have decided on a better approach?

This issue really requires a quick fix as the Synapse Docker guide currently does not work due to this problem.

1reaction
flavienbwkcommented, May 12, 2021

Same problem. I’ve edited the logging strategy as-is to make it work :

    filename: /data/homeserver.log
Read more comments on GitHub >

github_iconTop Results From Across the Web

Container permission denied: How to diagnose this error
Learn what is causing a container permissions error and how to work around the issue without resorting to the --privileged flag.
Read more >
Errno 13 Permission denied when Airflow tries to write to logs
Grant permission to the local folder, so that airflow container can write logs, create directory if needed etc.,
Read more >
Run the Docker daemon as a non-root user (Rootless mode)
To fix the issue, run sudo apt-get install -y dbus-user-session or sudo dnf install -y dbus-daemon , and then relogin. If the error...
Read more >
How to fix docker: Got permission denied while trying to ...
I've just installed docker but I have to run it with sudo every time. If I don't add sudo I get the following...
Read more >
Agent logging permission issues - Datadog Docs
Make sure that the Agent's log files as well as the directory that contains those files is owned by the Datadog Agent user:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found