From df3380edd85e3ea4c50bb82879c53d6dfa4e5443 Mon Sep 17 00:00:00 2001 From: Dev-iL <6509619+Dev-iL@users.noreply.github.com> Date: Sat, 14 Mar 2026 12:43:11 +0200 Subject: [PATCH 1/2] Limit no-constraints fallback to bootstrap builds --- Dockerfile | 29 ++++++++++++++++++++++++++++- Dockerfile.ci | 29 ++++++++++++++++++++++++++++- scripts/docker/common.sh | 29 ++++++++++++++++++++++++++++- 3 files changed, 84 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index e074e6321c55f..757528b52affa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -764,7 +764,34 @@ function common::get_constraints_location() { echo echo "${COLOR_BLUE}Downloading constraints from ${AIRFLOW_CONSTRAINTS_LOCATION} to ${HOME}/constraints.txt ${COLOR_RESET}" echo - curl -sSf -o "${HOME}/constraints.txt" "${AIRFLOW_CONSTRAINTS_LOCATION}" + local http_code + if http_code=$(curl -sS -L -o "${HOME}/constraints.txt" -w "%{http_code}" "${AIRFLOW_CONSTRAINTS_LOCATION}"); then + if [[ ${http_code} == "200" ]]; then + return + fi + if [[ ${http_code} == "404" \ + && ${ALLOW_MISSING_PREVIOUS_CONSTRAINTS_FILE:="false"} == "true" \ + && ${AIRFLOW_FALLBACK_NO_CONSTRAINTS_INSTALLATION:="false"} == "true" ]]; then + echo + echo "${COLOR_YELLOW}Constraints file not found at ${AIRFLOW_CONSTRAINTS_LOCATION}.${COLOR_RESET}" + echo "${COLOR_YELLOW}Using an empty constraints file because bootstrap mode was explicitly enabled.${COLOR_RESET}" + echo + AIRFLOW_CONSTRAINTS_LOCATION="" + : > "${HOME}/constraints.txt" + return + fi + echo + echo "${COLOR_RED}Failed to download constraints from ${AIRFLOW_CONSTRAINTS_LOCATION} (HTTP ${http_code}).${COLOR_RESET}" + if [[ ${http_code} == "404" ]]; then + echo "${COLOR_RED}Only bootstrap builds should set both ALLOW_MISSING_PREVIOUS_CONSTRAINTS_FILE=true and AIRFLOW_FALLBACK_NO_CONSTRAINTS_INSTALLATION=true.${COLOR_RESET}" + fi + echo + return 1 + fi + echo + echo "${COLOR_RED}Failed to download constraints from ${AIRFLOW_CONSTRAINTS_LOCATION}.${COLOR_RESET}" + echo + return 1 else echo echo "${COLOR_BLUE}Copying constraints from ${AIRFLOW_CONSTRAINTS_LOCATION} to ${HOME}/constraints.txt ${COLOR_RESET}" diff --git a/Dockerfile.ci b/Dockerfile.ci index 0cf6fafd96774..e137fa71cdc6d 100644 --- a/Dockerfile.ci +++ b/Dockerfile.ci @@ -704,7 +704,34 @@ function common::get_constraints_location() { echo echo "${COLOR_BLUE}Downloading constraints from ${AIRFLOW_CONSTRAINTS_LOCATION} to ${HOME}/constraints.txt ${COLOR_RESET}" echo - curl -sSf -o "${HOME}/constraints.txt" "${AIRFLOW_CONSTRAINTS_LOCATION}" + local http_code + if http_code=$(curl -sS -L -o "${HOME}/constraints.txt" -w "%{http_code}" "${AIRFLOW_CONSTRAINTS_LOCATION}"); then + if [[ ${http_code} == "200" ]]; then + return + fi + if [[ ${http_code} == "404" \ + && ${ALLOW_MISSING_PREVIOUS_CONSTRAINTS_FILE:="false"} == "true" \ + && ${AIRFLOW_FALLBACK_NO_CONSTRAINTS_INSTALLATION:="false"} == "true" ]]; then + echo + echo "${COLOR_YELLOW}Constraints file not found at ${AIRFLOW_CONSTRAINTS_LOCATION}.${COLOR_RESET}" + echo "${COLOR_YELLOW}Using an empty constraints file because bootstrap mode was explicitly enabled.${COLOR_RESET}" + echo + AIRFLOW_CONSTRAINTS_LOCATION="" + : > "${HOME}/constraints.txt" + return + fi + echo + echo "${COLOR_RED}Failed to download constraints from ${AIRFLOW_CONSTRAINTS_LOCATION} (HTTP ${http_code}).${COLOR_RESET}" + if [[ ${http_code} == "404" ]]; then + echo "${COLOR_RED}Only bootstrap builds should set both ALLOW_MISSING_PREVIOUS_CONSTRAINTS_FILE=true and AIRFLOW_FALLBACK_NO_CONSTRAINTS_INSTALLATION=true.${COLOR_RESET}" + fi + echo + return 1 + fi + echo + echo "${COLOR_RED}Failed to download constraints from ${AIRFLOW_CONSTRAINTS_LOCATION}.${COLOR_RESET}" + echo + return 1 else echo echo "${COLOR_BLUE}Copying constraints from ${AIRFLOW_CONSTRAINTS_LOCATION} to ${HOME}/constraints.txt ${COLOR_RESET}" diff --git a/scripts/docker/common.sh b/scripts/docker/common.sh index 66a3b61e865e1..b34ee6f21df19 100644 --- a/scripts/docker/common.sh +++ b/scripts/docker/common.sh @@ -117,7 +117,34 @@ function common::get_constraints_location() { echo echo "${COLOR_BLUE}Downloading constraints from ${AIRFLOW_CONSTRAINTS_LOCATION} to ${HOME}/constraints.txt ${COLOR_RESET}" echo - curl -sSf -o "${HOME}/constraints.txt" "${AIRFLOW_CONSTRAINTS_LOCATION}" + local http_code + if http_code=$(curl -sS -L -o "${HOME}/constraints.txt" -w "%{http_code}" "${AIRFLOW_CONSTRAINTS_LOCATION}"); then + if [[ ${http_code} == "200" ]]; then + return + fi + if [[ ${http_code} == "404" \ + && ${ALLOW_MISSING_PREVIOUS_CONSTRAINTS_FILE:="false"} == "true" \ + && ${AIRFLOW_FALLBACK_NO_CONSTRAINTS_INSTALLATION:="false"} == "true" ]]; then + echo + echo "${COLOR_YELLOW}Constraints file not found at ${AIRFLOW_CONSTRAINTS_LOCATION}.${COLOR_RESET}" + echo "${COLOR_YELLOW}Using an empty constraints file because bootstrap mode was explicitly enabled.${COLOR_RESET}" + echo + AIRFLOW_CONSTRAINTS_LOCATION="" + : > "${HOME}/constraints.txt" + return + fi + echo + echo "${COLOR_RED}Failed to download constraints from ${AIRFLOW_CONSTRAINTS_LOCATION} (HTTP ${http_code}).${COLOR_RESET}" + if [[ ${http_code} == "404" ]]; then + echo "${COLOR_RED}Only bootstrap builds should set both ALLOW_MISSING_PREVIOUS_CONSTRAINTS_FILE=true and AIRFLOW_FALLBACK_NO_CONSTRAINTS_INSTALLATION=true.${COLOR_RESET}" + fi + echo + return 1 + fi + echo + echo "${COLOR_RED}Failed to download constraints from ${AIRFLOW_CONSTRAINTS_LOCATION}.${COLOR_RESET}" + echo + return 1 else echo echo "${COLOR_BLUE}Copying constraints from ${AIRFLOW_CONSTRAINTS_LOCATION} to ${HOME}/constraints.txt ${COLOR_RESET}" From 77a2a7f955ed041f91277f84ae33d3d0d99acde4 Mon Sep 17 00:00:00 2001 From: Dev-iL <6509619+Dev-iL@users.noreply.github.com> Date: Sat, 14 Mar 2026 12:31:39 +0200 Subject: [PATCH 2/2] Handle first constraints generation for new Python versions --- ...elease-management_generate-constraints.svg | 74 ++++++---- ...elease-management_generate-constraints.txt | 2 +- .../commands/release_management_commands.py | 11 ++ .../release_management_commands_config.py | 1 + .../src/airflow_breeze/params/shell_params.py | 6 + .../tests/test_release_management_commands.py | 52 +++++++ dev/breeze/tests/test_shell_params.py | 8 + .../in_container/run_generate_constraints.py | 67 +++++++-- scripts/pyproject.toml | 3 +- .../tests/scripts/in_container/__init__.py | 16 ++ .../test_run_generate_constraints.py | 139 ++++++++++++++++++ uv.lock | 2 + 12 files changed, 345 insertions(+), 36 deletions(-) create mode 100644 dev/breeze/tests/test_release_management_commands.py create mode 100644 scripts/tests/scripts/in_container/__init__.py create mode 100644 scripts/tests/scripts/in_container/test_run_generate_constraints.py diff --git a/dev/breeze/doc/images/output_release-management_generate-constraints.svg b/dev/breeze/doc/images/output_release-management_generate-constraints.svg index 46cfb481b7801..75276c2db05dc 100644 --- a/dev/breeze/doc/images/output_release-management_generate-constraints.svg +++ b/dev/breeze/doc/images/output_release-management_generate-constraints.svg @@ -1,4 +1,4 @@ - +