Skip to content

fix: handle PermissionError in init_log_folder for mounted filesystems#63878

Open
Pranaykarvi wants to merge 1 commit intoapache:mainfrom
Pranaykarvi:fix-init-log-folder-permission-error
Open

fix: handle PermissionError in init_log_folder for mounted filesystems#63878
Pranaykarvi wants to merge 1 commit intoapache:mainfrom
Pranaykarvi:fix-init-log-folder-permission-error

Conversation

@Pranaykarvi
Copy link
Contributor

Problem

init_log_folder() iterates through all parent directories from / calling mkdir() on each. For paths on mounted filesystems (e.g. /mnt/nfs-share/airflow/logs), this calls mkdir('/mnt') and mkdir('/mnt/nfs-share') which fails with PermissionError because the Airflow user cannot create system-level directories. exist_ok=True only suppresses FileExistsError, not PermissionError, crashing all Airflow CLI commands including airflow db migrate.

Fix

  • Replaced the explicit parent loop in init_log_folder() with Path.mkdir(parents=True, exist_ok=True) which only creates directories that don't already exist, stopping at the first existing parent
  • Wrapped the call in try/except (PermissionError, OSError) to log a warning instead of crashing
  • Wrapped the init_log_folder() call in configure_logging() with the same try/except so CLI commands continue even if the log folder cannot be created

Fixes #63863

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

init_log_folder raises PermissionError when base_log_folder is on a mounted filesystem

1 participant