Skip to content

Commit

Permalink
Check executable permission for entrypoints at breeze start (apache#3…
Browse files Browse the repository at this point in the history
…6482)

* Check executable permission for entrypoints at breeze start

Sometimes our contributors check out Airflow repository on filesystems
that are not POSIX compliant and do not have support for executable bits
(for example when you check-out the repository in Windows and attempt to
map it to a Linux VM). Breeze and building CI images will not
work in this case, but the error that you see might be misleading.

This PR performs additional environment check and informs you that
you should not do it, if executable bits are missing from entrypoints.

* Update dev/breeze/src/airflow_breeze/utils/docker_command_utils.py

Co-authored-by: Jens Scheffler <[email protected]>

---------

Co-authored-by: Jens Scheffler <[email protected]>
  • Loading branch information
potiuk and jscheffl authored Dec 29, 2023
1 parent 7cd326c commit 5551e14
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
21 changes: 21 additions & 0 deletions dev/breeze/src/airflow_breeze/utils/docker_command_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from airflow_breeze.utils.host_info_utils import get_host_group_id, get_host_os, get_host_user_id
from airflow_breeze.utils.path_utils import (
AIRFLOW_SOURCES_ROOT,
SCRIPTS_DOCKER_DIR,
cleanup_python_generated_files,
create_mypy_volume_if_needed,
)
Expand Down Expand Up @@ -481,10 +482,30 @@ def prepare_broker_url(params, env_variables):
env_variables["AIRFLOW__CELERY__BROKER_URL"] = url_map[params.celery_broker]


def check_executable_entrypoint_permissions(quiet: bool = False):
"""
Checks if the user has executable permissions on the entrypoints in checked-out airflow repository..
"""
for entrypoint in SCRIPTS_DOCKER_DIR.glob("entrypoint*.sh"):
if get_verbose() and not quiet:
get_console().print(f"[info]Checking executable permissions on {entrypoint.as_posix()}[/]")
if not os.access(entrypoint.as_posix(), os.X_OK):
get_console().print(
f"[error]You do not have executable permissions on {entrypoint}[/]\n"
f"You likely checked out airflow repo on a filesystem that does not support executable "
f"permissions (for example on a Windows filesystem that is mapped to Linux VM). Airflow "
f"repository should only be checked out on a filesystem that is POSIX compliant."
)
sys.exit(1)
if not quiet:
get_console().print("[success]Executable permissions on entrypoints are OK[/]")


def perform_environment_checks(quiet: bool = False):
check_docker_is_running()
check_docker_version(quiet)
check_docker_compose_version(quiet)
check_executable_entrypoint_permissions(quiet)


def get_docker_syntax_version() -> str:
Expand Down
1 change: 1 addition & 0 deletions dev/breeze/src/airflow_breeze/utils/path_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ def find_airflow_sources_root_to_operate_on() -> Path:
GENERATED_PROVIDER_PACKAGES_DIR = DIST_DIR / "provider_packages"
DOCS_DIR = AIRFLOW_SOURCES_ROOT / "docs"
SCRIPTS_CI_DIR = AIRFLOW_SOURCES_ROOT / "scripts" / "ci"
SCRIPTS_DOCKER_DIR = AIRFLOW_SOURCES_ROOT / "scripts" / "docker"
SCRIPTS_CI_DOCKER_COMPOSE_DIR = SCRIPTS_CI_DIR / "docker-compose"
SCRIPTS_CI_DOCKER_COMPOSE_LOCAL_YAML_FILE = SCRIPTS_CI_DOCKER_COMPOSE_DIR / "local.yml"
GENERATED_DOCKER_COMPOSE_ENV_FILE = SCRIPTS_CI_DOCKER_COMPOSE_DIR / "_generated_docker_compose.env"
Expand Down

0 comments on commit 5551e14

Please sign in to comment.