Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: extraPipPackages values for airflow 2.9.0+ #858

Merged
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
29 changes: 25 additions & 4 deletions charts/airflow/templates/_helpers/pods.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,31 @@ EXAMPLE USAGE: {{ include "airflow.init_container.install_pip_packages" (dict "R
- "bash"
- "-c"
- |
unset PYTHONUSERBASE && \
pip freeze | grep -i {{ range .Values.airflow.protectedPipPackages }}-e {{ printf "%s==" . | quote }} {{ end }} > protected-packages.txt && \
pip install --constraint ./protected-packages.txt --user {{ range .extraPipPackages }}{{ . | quote }} {{ end }} && \
echo "copying '/home/airflow/.local/' to '/opt/home-airflow-local/.local/'..." && \
set -euo pipefail

echo "DANGER: the 'extraPipPackages' feature may cause unexpected runtime errors!"
echo "DANGER: consider building a custom image with the required packages!"
echo ""

pip freeze | grep -i {{ range .Values.airflow.protectedPipPackages }}-e {{ printf "%s==" . | squote }} {{ end }} > protected-packages.txt
{{- range .extraPipPackages }}
echo {{ . | squote }} >> requested-packages.txt
{{- end }}
echo "INFO: ==== PROTECTED PACKAGES ====" && cat protected-packages.txt && echo ""
echo "INFO: ==== REQUESTED PACKAGES ====" && cat requested-packages.txt && echo ""

echo "INFO: ==== RUNNING PIP INSTALL ===="
if [ -n "${VIRTUAL_ENV:-}" ]; then
# airflow >2.9.0 uses virtualenv
pip install --constraint ./protected-packages.txt --requirement ./requested-packages.txt
else
# airflow <2.9.0 uses user-site
pip install --constraint ./protected-packages.txt --requirement ./requested-packages.txt --user
fi
echo ""

echo "INFO: ==== COPYING PACKAGES TO VOLUME ===="
echo "INFO: copying from '/home/airflow/.local/' to '/opt/home-airflow-local/.local/'"
rsync -ah --stats --delete /home/airflow/.local/ /opt/home-airflow-local/.local/
volumeMounts:
- name: home-airflow-local
Expand Down
Loading