Skip to content

Commit d4624fa

Browse files
fix: extraPipPackages values for airflow 2.9.0+ (#858)
Signed-off-by: Mathew Wicks <[email protected]>
1 parent 912a037 commit d4624fa

File tree

1 file changed

+25
-4
lines changed
  • charts/airflow/templates/_helpers

1 file changed

+25
-4
lines changed

charts/airflow/templates/_helpers/pods.tpl

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,31 @@ EXAMPLE USAGE: {{ include "airflow.init_container.install_pip_packages" (dict "R
191191
- "bash"
192192
- "-c"
193193
- |
194-
unset PYTHONUSERBASE && \
195-
pip freeze | grep -i {{ range .Values.airflow.protectedPipPackages }}-e {{ printf "%s==" . | quote }} {{ end }} > protected-packages.txt && \
196-
pip install --constraint ./protected-packages.txt --user {{ range .extraPipPackages }}{{ . | quote }} {{ end }} && \
197-
echo "copying '/home/airflow/.local/' to '/opt/home-airflow-local/.local/'..." && \
194+
set -euo pipefail
195+
196+
echo "DANGER: the 'extraPipPackages' feature may cause unexpected runtime errors!"
197+
echo "DANGER: consider building a custom image with the required packages!"
198+
echo ""
199+
200+
pip freeze | grep -i {{ range .Values.airflow.protectedPipPackages }}-e {{ printf "%s==" . | squote }} {{ end }} > protected-packages.txt
201+
{{- range .extraPipPackages }}
202+
echo {{ . | squote }} >> requested-packages.txt
203+
{{- end }}
204+
echo "INFO: ==== PROTECTED PACKAGES ====" && cat protected-packages.txt && echo ""
205+
echo "INFO: ==== REQUESTED PACKAGES ====" && cat requested-packages.txt && echo ""
206+
207+
echo "INFO: ==== RUNNING PIP INSTALL ===="
208+
if [ -n "${VIRTUAL_ENV:-}" ]; then
209+
# airflow >2.9.0 uses virtualenv
210+
pip install --constraint ./protected-packages.txt --requirement ./requested-packages.txt
211+
else
212+
# airflow <2.9.0 uses user-site
213+
pip install --constraint ./protected-packages.txt --requirement ./requested-packages.txt --user
214+
fi
215+
echo ""
216+
217+
echo "INFO: ==== COPYING PACKAGES TO VOLUME ===="
218+
echo "INFO: copying from '/home/airflow/.local/' to '/opt/home-airflow-local/.local/'"
198219
rsync -ah --stats --delete /home/airflow/.local/ /opt/home-airflow-local/.local/
199220
volumeMounts:
200221
- name: home-airflow-local

0 commit comments

Comments
 (0)