This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 5551e14f6c Check executable permission for entrypoints at breeze start 
(#36482)
5551e14f6c is described below

commit 5551e14f6c0d8706bf8beaaab6a8fa5c80719a89
Author: Jarek Potiuk <ja...@potiuk.com>
AuthorDate: Fri Dec 29 12:47:48 2023 +0100

    Check executable permission for entrypoints at breeze start (#36482)
    
    * 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 <95105677+jsche...@users.noreply.github.com>
    
    ---------
    
    Co-authored-by: Jens Scheffler <95105677+jsche...@users.noreply.github.com>
---
 .../airflow_breeze/utils/docker_command_utils.py    | 21 +++++++++++++++++++++
 dev/breeze/src/airflow_breeze/utils/path_utils.py   |  1 +
 2 files changed, 22 insertions(+)

diff --git a/dev/breeze/src/airflow_breeze/utils/docker_command_utils.py 
b/dev/breeze/src/airflow_breeze/utils/docker_command_utils.py
index bc54b9bf69..5c8e98056d 100644
--- a/dev/breeze/src/airflow_breeze/utils/docker_command_utils.py
+++ b/dev/breeze/src/airflow_breeze/utils/docker_command_utils.py
@@ -30,6 +30,7 @@ from airflow_breeze.utils.cache import read_from_cache_file
 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,
 )
@@ -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:
diff --git a/dev/breeze/src/airflow_breeze/utils/path_utils.py 
b/dev/breeze/src/airflow_breeze/utils/path_utils.py
index 6e701e0c24..21644a1dd9 100644
--- a/dev/breeze/src/airflow_breeze/utils/path_utils.py
+++ b/dev/breeze/src/airflow_breeze/utils/path_utils.py
@@ -291,6 +291,7 @@ DIST_DIR = AIRFLOW_SOURCES_ROOT / "dist"
 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"

Reply via email to