Skip to content

Commit

Permalink
Fixes default group of Airflow user. (apache#14944)
Browse files Browse the repository at this point in the history
The production image did not have root group set as default for
the airflow user. This was not a big problem unless you extended
the image - in which case you had to change the group manually
when copying the images in order to keep the image OpenShift
compatible (i.e. runnable with any user and root group).

This PR fixes it by changing default group of airflow user
to root, which also works when you extend the image.

```
Connected.
airflow@53f70b1e3675:/opt/airflow$ ls
dags  logs
airflow@53f70b1e3675:/opt/airflow$ cd dags/
airflow@53f70b1e3675:/opt/airflow/dags$ ls -l
total 4
-rw-r--r-- 1 airflow root 1648 Mar 22 23:16 test_dag.py
airflow@53f70b1e3675:/opt/airflow/dags$
```
  • Loading branch information
potiuk authored Mar 23, 2021
1 parent 6d30464 commit 26d96af
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,8 @@ WORKDIR ${AIRFLOW_HOME}

EXPOSE 8080

RUN usermod -g 0 airflow

USER ${AIRFLOW_UID}

# Having the variable in final image allows to disable providers manager warnings when
Expand Down
16 changes: 16 additions & 0 deletions docs/helm-chart/manage-dags-files.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,21 @@ Bake DAGs in Docker image

The recommended way to update your DAGs with this chart is to build a new docker image with the latest DAG code:

.. code-block:: bash
docker build --tag "my-company/airflow:8a0da78" . -f - <<EOF
FROM apache/airflow
COPY ./dags/ \${AIRFLOW_HOME}/dags/
EOF
.. note::
In airflow images prior to version 2.0.2, there was a bug that required you to use
a bit longer Dockerfile, to make sure the image remains OpenShift-compatible (i.e dag
has root group similarly as other files). In 2.0.2 this has been fixed.
.. code-block:: bash
docker build --tag "my-company/airflow:8a0da78" . -f - <<EOF
Expand All @@ -38,6 +53,7 @@ The recommended way to update your DAGs with this chart is to build a new docker
EOF
Then publish it in the accessible registry:
.. code-block:: bash
Expand Down
8 changes: 2 additions & 6 deletions scripts/ci/libraries/_kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,9 @@ function kind::build_image_for_kubernetes_tests() {
docker build --tag "${AIRFLOW_PROD_IMAGE_KUBERNETES}" . -f - <<EOF
FROM ${AIRFLOW_PROD_IMAGE}
USER root
COPY airflow/example_dags/ \${AIRFLOW_HOME}/dags/
COPY --chown=airflow:root airflow/example_dags/ \${AIRFLOW_HOME}/dags/
COPY --chown=airflow:root airflow/kubernetes_executor_templates/ \${AIRFLOW_HOME}/pod_templates/
USER airflow
COPY airflow/kubernetes_executor_templates/ \${AIRFLOW_HOME}/pod_templates/
EOF
echo "The ${AIRFLOW_PROD_IMAGE_KUBERNETES} is prepared for test kubernetes deployment."
Expand Down

0 comments on commit 26d96af

Please sign in to comment.