diff --git a/Dockerfile b/Dockerfile index 179491e0d306f..df0bceccb30aa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -424,7 +424,7 @@ function install_python() { find /usr/python -depth \ \( \ \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ - -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \ + -o \( -type f -a \( -name 'libpython*.a' \) \) \ \) -exec rm -rf '{}' + link_python } diff --git a/Dockerfile.ci b/Dockerfile.ci index b015822fbe6ba..b69ab45dedac6 100644 --- a/Dockerfile.ci +++ b/Dockerfile.ci @@ -363,7 +363,7 @@ function install_python() { find /usr/python -depth \ \( \ \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ - -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \ + -o \( -type f -a \( -name 'libpython*.a' \) \) \ \) -exec rm -rf '{}' + link_python } diff --git a/docker-stack-docs/changelog.rst b/docker-stack-docs/changelog.rst index d1073bf578808..b0d5e192d2ad5 100644 --- a/docker-stack-docs/changelog.rst +++ b/docker-stack-docs/changelog.rst @@ -34,6 +34,18 @@ the Airflow team. any Airflow version from the ``Airflow 2`` line. There is no guarantee that it will work, but if it does, then you can use latest features from that image to build images for previous Airflow versions. +Airflow 3.1.4 +~~~~~~~~~~~~~ + +In Airflow 3.1.4, the images are build without removing of .pyc and .pyo files when Python is built. +This increases the size of the image slightly (<0.5%), but improves performance of Python in the container +because Python does not need to recompile the files on the first run but more importantly, if you use +``exec`` to run Health Checks, removed .pyc files caused a small but ever growing memory leak in the Unix +kernel connected to negative ``dentries`` created when .pyc files were attempted to be compiled and failed. +This over time could lead to out-of-memory issues on the host running the container. + +More information about ``dentries`` can be found in `this article `_. + Airflow 3.1.0 ~~~~~~~~~~~~~ diff --git a/scripts/docker/install_os_dependencies.sh b/scripts/docker/install_os_dependencies.sh index 75151bb1f0e89..26d01db8a5efc 100644 --- a/scripts/docker/install_os_dependencies.sh +++ b/scripts/docker/install_os_dependencies.sh @@ -331,7 +331,7 @@ function install_python() { find /usr/python -depth \ \( \ \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ - -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \ + -o \( -type f -a \( -name 'libpython*.a' \) \) \ \) -exec rm -rf '{}' + link_python }