Tutor dev HOST_USER_ID on Windows 10 causing containers to exit [Errno 13] Permission denied: '/openedx/data/logs/all.log'

Hi all,

I’m wondering if you can help with some problems I’m having with tutor dev. When trying to launch the containers, both the lms and cms containers keep exiting.

CMS

2024-02-14 10:46:00 PermissionError: [Errno 13] Permission denied: '/openedx/data/logs/all.log'
2024-02-14 10:46:00 
2024-02-14 10:46:00 The above exception was the direct cause of the following exception:
2024-02-14 10:46:00 
2024-02-14 10:46:00 Traceback (most recent call last):
2024-02-14 10:46:00   File "./manage.py", line 103, in <module>
2024-02-14 10:46:00     startup.run()
2024-02-14 10:46:00   File "/openedx/edx-platform/cms/startup.py", line 20, in run
2024-02-14 10:46:00     django.setup()
2024-02-14 10:46:00   File "/openedx/venv/lib/python3.8/site-packages/django/__init__.py", line 19, in setup
2024-02-14 10:46:00     configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
2024-02-14 10:46:00   File "/openedx/venv/lib/python3.8/site-packages/django/utils/log.py", line 76, in configure_logging
2024-02-14 10:46:00     logging_config_func(logging_settings)
2024-02-14 10:46:00   File "/opt/pyenv/versions/3.8.18/lib/python3.8/logging/config.py", line 808, in dictConfig
2024-02-14 10:46:00     dictConfigClass(config).configure()
2024-02-14 10:46:00   File "/opt/pyenv/versions/3.8.18/lib/python3.8/logging/config.py", line 570, in configure
2024-02-14 10:46:00     raise ValueError('Unable to configure handler '
2024-02-14 10:46:00 ValueError: Unable to configure handler 'local'

LMS

2024-02-14 10:48:05 PermissionError: [Errno 13] Permission denied: '/openedx/data/logs/all.log'
2024-02-14 10:48:05 
2024-02-14 10:48:05 The above exception was the direct cause of the following exception:
2024-02-14 10:48:05 
2024-02-14 10:48:05 Traceback (most recent call last):
2024-02-14 10:48:05   File "./manage.py", line 103, in <module>
2024-02-14 10:48:05     startup.run()
2024-02-14 10:48:05   File "/openedx/edx-platform/lms/startup.py", line 20, in run
2024-02-14 10:48:05     django.setup()
2024-02-14 10:48:05   File "/openedx/venv/lib/python3.8/site-packages/django/__init__.py", line 19, in setup
2024-02-14 10:48:05     configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
2024-02-14 10:48:05   File "/openedx/venv/lib/python3.8/site-packages/django/utils/log.py", line 76, in configure_logging
2024-02-14 10:48:05     logging_config_func(logging_settings)
2024-02-14 10:48:05   File "/opt/pyenv/versions/3.8.18/lib/python3.8/logging/config.py", line 808, in dictConfig
2024-02-14 10:48:05     dictConfigClass(config).configure()
2024-02-14 10:48:05   File "/opt/pyenv/versions/3.8.18/lib/python3.8/logging/config.py", line 570, in configure
2024-02-14 10:48:05     raise ValueError('Unable to configure handler '
2024-02-14 10:48:05 ValueError: Unable to configure handler 'local'
2024-02-14 10:49:06 Traceback (most recent call last):
2024-02-14 10:49:06   File "/opt/pyenv/versions/3.8.18/lib/python3.8/logging/config.py", line 563, in configure
2024-02-14 10:49:06     handler = self.configure_handler(handlers[name])
2024-02-14 10:49:06   File "/opt/pyenv/versions/3.8.18/lib/python3.8/logging/config.py", line 744, in configure_handler
2024-02-14 10:49:06     result = factory(**kwargs)
2024-02-14 10:49:06   File "/opt/pyenv/versions/3.8.18/lib/python3.8/logging/handlers.py", line 435, in __init__
2024-02-14 10:49:06     logging.FileHandler.__init__(self, filename, mode, encoding, delay)
2024-02-14 10:49:06   File "/opt/pyenv/versions/3.8.18/lib/python3.8/logging/__init__.py", line 1147, in __init__
2024-02-14 10:49:06     StreamHandler.__init__(self, self._open())
2024-02-14 10:49:06   File "/opt/pyenv/versions/3.8.18/lib/python3.8/logging/__init__.py", line 1176, in _open
2024-02-14 10:49:06     return open(self.baseFilename, self.mode, encoding=self.encoding)

This is only the case with tutor dev. tutor local is able to read and write to the log files absolutely fine. Does anyone have any idea how I could fix this issue?

Update

Found a post that seemed to be a similar permissions issue. @dianamoonlight did you ever find a solution?

The following has worked for me (on Windows, Tutor version 17.0.2)

I added HOST_USER_ID: '1000' to config.yml.

In the Compose file for tutor local the OPENEDX_USER_ID is hardcoded to “1000”

...
permissions:
    image: {{ DOCKER_IMAGE_PERMISSIONS }}
    restart: on-failure
    entrypoint: []
    command: ["sh", "/usr/local/bin/setowners.sh"]
    environment:
      OPENEDX_USER_ID: "1000"
....

Whereas in the Compose file for tutor dev it is set to the HOST_USER_ID variable

...
services:
  permissions:
    environment:
      OPENEDX_USER_ID: "{{ HOST_USER_ID }}"
...

This is because HOST_USER_ID is set by utils.get_user_id(), which on Windows returns 0.

def get_user_id() -> int:
    """
    Portable way to get user ID. Note: I have no idea if it actually works on windows...
    """
    if sys.platform != "win32":
        return os.getuid()

    # Don't even try for windows
    return 0

There’s something I don’t understand. Who is the owner of the all.log files? And under what user do the lms/cms operate in the Docker containers?

When HOST_USER_ID is not set, I get the following:

The permissions container sets the owner of the mounts to root

drwxr-xr-x 1 root app     4096 Feb 14 15:55 .
drwxrwxrwx 1 root root    4096 Feb 14 15:55 ..
-rw-r--r-- 1 root app  1033825 Feb 27 09:14 all.log
-rw-r--r-- 1 root app   856053 Feb 16 16:20 tracking.log

Looks like the containers still run with user 1000 docker exec -it {LMScontainer} bash -c "echo $UID"

This issue is now tracked here: On Windows `tutor dev start` fails because of "Permission denied" · Issue #1034 · overhangio/tutor · GitHub A fix is proposed there.

1 Like