Skip to content

Commit

Permalink
FIX Entrypoint and _CMD config variables (#8705)
Browse files Browse the repository at this point in the history
The entrypoint manages the two variables AIRFLOW__CORE__SQL_ALCHEMY_CONN and AIRFLOW__CELERY__BROKER_URL but does not take into account the fact that those configurations can be overriden by AIRFLOW__CORE__SQL_ALCHEMY_CONN_CMD and AIRFLOW__CELERY__BROKER_URL_CMD which is very useful when providing the connections to those endpoints using Swarm/Kubernetes secrets.

The Dockerfile and its entrypoint come from the 2.0 refactoring (master branch) and have been backported to the 1.10 branch. Since the _CMD behaviour is present in the 1.10 stable branch the fix should be done there.
  • Loading branch information
NBardelot committed May 4, 2020
1 parent a943d6b commit e5336a4
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,28 @@ function verify_db_connection {
fi
}

# if no DB configured - use sqlite db by default
AIRFLOW__CORE__SQL_ALCHEMY_CONN="${AIRFLOW__CORE__SQL_ALCHEMY_CONN:="sqlite:///${AIRFLOW_HOME}/airflow.db"}"

verify_db_connection "${AIRFLOW__CORE__SQL_ALCHEMY_CONN}"

AIRFLOW__CELERY__BROKER_URL=${AIRFLOW__CELERY__BROKER_URL:=}
# Warning: command environnement variables (*_CMD) have priority over usual configuration variables
# for configuration parameters that require sensitive information. This is the case for the SQL database
# and the broker backend in this entrypoint script.

if [[ -n "$AIRFLOW__CORE__SQL_ALCHEMY_CONN_CMD" ]]; then
verify_db_connection "$(eval "$AIRFLOW__CORE__SQL_ALCHEMY_CONN_CMD")"
else
# if no DB configured - use sqlite db by default
AIRFLOW__CORE__SQL_ALCHEMY_CONN="${AIRFLOW__CORE__SQL_ALCHEMY_CONN:="sqlite:///${AIRFLOW_HOME}/airflow.db"}"
verify_db_connection "${AIRFLOW__CORE__SQL_ALCHEMY_CONN}"
fi

if [[ -n ${AIRFLOW__CELERY__BROKER_URL} ]] && \
[[ ${AIRFLOW_COMMAND} =~ ^(scheduler|worker|flower)$ ]]; then
verify_db_connection "${AIRFLOW__CELERY__BROKER_URL}"
# Note: the broker backend configuration concerns only a subset of Airflow components
if [[ "${AIRFLOW_COMMAND}" =~ ^(scheduler|worker|flower)$ ]]; then
if [[ -n "$AIRFLOW__CELERY__BROKER_URL_CMD" ]]; then
verify_db_connection "$(eval "$AIRFLOW__CELERY__BROKER_URL_CMD")"
else
AIRFLOW__CELERY__BROKER_URL=${AIRFLOW__CELERY__BROKER_URL:=}
if [[ -n "${AIRFLOW__CELERY__BROKER_URL}" ]]; then
verify_db_connection "${AIRFLOW__CELERY__BROKER_URL}"
fi
fi
fi

if [[ ${AIRFLOW_COMMAND} == "" ]]; then
Expand Down

0 comments on commit e5336a4

Please sign in to comment.