Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -1417,6 +1417,14 @@ EOF
COPY <<"EOF" /entrypoint_prod.sh
#!/usr/bin/env bash
AIRFLOW_COMMAND="${1:-}"
AIRFLOW_COMMAND_TO_RUN="${AIRFLOW_COMMAND}"
if [[ "${AIRFLOW_COMMAND}" == "airflow" ]]; then
AIRFLOW_COMMAND_TO_RUN="${2:-}"
elif [[ "${AIRFLOW_COMMAND}" =~ ^(bash|sh)$ ]] \
&& [[ "${2:-}" == "-c" ]] \
&& [[ "${3:-}" =~ (^|[[:space:]])(exec[[:space:]]+)?airflow[[:space:]]+(scheduler|dag-processor|triggerer|api-server)([[:space:]]|$) ]]; then
AIRFLOW_COMMAND_TO_RUN="${BASH_REMATCH[3]}"
fi

set -euo pipefail

Expand Down Expand Up @@ -1668,7 +1676,8 @@ readonly CONNECTION_CHECK_SLEEP_TIME

create_system_user_if_missing
set_pythonpath_for_root_user
if [[ "${CONNECTION_CHECK_MAX_COUNT}" -gt "0" ]]; then
if [[ "${CONNECTION_CHECK_MAX_COUNT}" -gt "0" ]] \
&& [[ ${AIRFLOW_COMMAND_TO_RUN} =~ ^(scheduler|dag-processor|triggerer|api-server)$ ]]; then
wait_for_airflow_db
fi

Expand Down
14 changes: 11 additions & 3 deletions scripts/docker/entrypoint_prod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@
# under the License.
# Might be empty
AIRFLOW_COMMAND="${1:-}"
AIRFLOW_COMMAND_TO_RUN="${AIRFLOW_COMMAND}"
if [[ "${AIRFLOW_COMMAND}" == "airflow" ]]; then
AIRFLOW_COMMAND_TO_RUN="${2:-}"
elif [[ "${AIRFLOW_COMMAND}" =~ ^(bash|sh)$ ]] \
&& [[ "${2:-}" == "-c" ]] \
&& [[ "${3:-}" =~ (^|[[:space:]])(exec[[:space:]]+)?airflow[[:space:]]+(scheduler|dag-processor|triggerer|api-server)([[:space:]]|$) ]]; then
AIRFLOW_COMMAND_TO_RUN="${BASH_REMATCH[3]}"
fi

set -euo pipefail

Expand Down Expand Up @@ -283,7 +291,8 @@ readonly CONNECTION_CHECK_SLEEP_TIME

create_system_user_if_missing
set_pythonpath_for_root_user
if [[ "${CONNECTION_CHECK_MAX_COUNT}" -gt "0" ]]; then
if [[ "${CONNECTION_CHECK_MAX_COUNT}" -gt "0" ]] \
&& [[ ${AIRFLOW_COMMAND_TO_RUN} =~ ^(scheduler|dag-processor|triggerer|api-server)$ ]]; then
wait_for_airflow_db
fi

Expand Down Expand Up @@ -316,8 +325,7 @@ if [[ -n "${_PIP_ADDITIONAL_REQUIREMENTS=}" ]] ; then
fi


# The `bash` and `python` commands should also verify the basic connections
# So they are run after the DB check
# Handle direct `bash` and `python` passthrough commands.
exec_to_bash_or_python_command_if_specified "${@}"

# Remove "airflow" if it is specified as airflow command
Expand Down
Loading