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/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 @@ - +