airflow를 실행하려고 할 때 발생하는 Permission Denied 오류 해결 방법에 대해 설명하고자 한다.
situation
airflow-worker_1 | Traceback (most recent call last):
airflow-worker_1 | File "/usr/local/lib/python3.7/logging/config.py", line 563, in configure
airflow-worker_1 | handler = self.configure_handler(handlers[name])
airflow-worker_1 | File "/usr/local/lib/python3.7/logging/config.py", line 736, in configure_handler
airflow-worker_1 | result = factory(**kwargs)
airflow-worker_1 | File "/home/airflow/.local/lib/python3.7/site-packages/airflow/utils/log/file_processor_handler.py", line 49, in __init__
airflow-worker_1 | Path(self._get_log_directory()).mkdir(parents=True, exist_ok=True)
airflow-worker_1 | File "/usr/local/lib/python3.7/pathlib.py", line 1277, in mkdir
airflow-worker_1 | self.parent.mkdir(parents=True, exist_ok=True)
airflow-worker_1 | File "/usr/local/lib/python3.7/pathlib.py", line 1273, in mkdir
airflow-worker_1 | self._accessor.mkdir(self, mode)
airflow-worker_1 | PermissionError: [Errno 13] Permission denied: '/opt/airflow/logs/scheduler'
airflow-worker_1 |
airflow-worker_1 | The above exception was the direct cause of the following exception:
airflow-worker_1 |
airflow-worker_1 | Traceback (most recent call last):
airflow-worker_1 | File "/home/airflow/.local/bin/airflow", line 5, in <module>
airflow-worker_1 | from airflow.__main__ import main
airflow-worker_1 | File "/home/airflow/.local/lib/python3.7/site-packages/airflow/__init__.py", line 55, in <module>
airflow-worker_1 | settings.initialize()
airflow-worker_1 | File "/home/airflow/.local/lib/python3.7/site-packages/airflow/settings.py", line 569, in initialize
airflow-worker_1 | LOGGING_CLASS_PATH = configure_logging()
airflow-worker_1 | File "/home/airflow/.local/lib/python3.7/site-packages/airflow/logging_config.py", line 74, in configure_logging
airflow-worker_1 | raise e
airflow-worker_1 | File "/home/airflow/.local/lib/python3.7/site-packages/airflow/logging_config.py", line 69, in configure_logging
airflow-worker_1 | dictConfig(logging_config)
airflow-worker_1 | File "/usr/local/lib/python3.7/logging/config.py", line 800, in dictConfig
airflow-worker_1 | dictConfigClass(config).configure()
airflow-worker_1 | File "/usr/local/lib/python3.7/logging/config.py", line 571, in configure
airflow-worker_1 | '%r' % name) from e
airflow-worker_1 | ValueError: Unable to configure handler 'processor'
이 오류는 /logs에 대한 권한 문제로 인해 발생한다. 따라서 worker 뿐만 아니라 logs에 접근하고자 하는 sheduler, webserver 등 모든 요소에서 이 오류가 발생했을 것이다.
solution
1. 먼저, 오류 메세지에 나온 디렉토리 경로와 파일 권한을 확인하다. 오류 메세지에 나온 디렉토리는 로그 디렉토리이다.
2. mkdir 명령어를 사용하여 로그 디렉토리와 필요한 하위 디렉토리를 생성한다. 만약 만들어져 있다면 생략해도 된다.
mkdir -p dags logs plugins
3. 생성한 디렉토리들의 소유자와 그룹을 airflow 프로세스의 실행 사용자와 일치하도록 변경한다.
chown 50000:50000 dags logs plugins
50000은 UID(사용자 ID)와 GID(그룹 ID)이다. 이 값은 airflow 환경에서 사용되는 값이다.
이제 airflow를 다시 실행시키면 권한 문제로 인한 오류가 해결된다.
반응형