Skip to content

Commit d074196

Browse files
committed
Add error handling in pre-install hook
1 parent 66b4684 commit d074196

File tree

1 file changed

+35
-7
lines changed

1 file changed

+35
-7
lines changed

chart/templates/dev-mode-code-pre-install-hook.yaml

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ metadata:
3131
annotations:
3232
helm.sh/hook: "pre-install"
3333
helm.sh/hook-weight: "5"
34-
# helm.sh/hook-delete-policy: hook-succeeded
34+
helm.sh/hook-delete-policy: "hook-succeeded,before-hook-creation"
35+
# Increase hook timeout to avoid timing out in CI environments
36+
helm.sh/hook-timeout-seconds: "300"
3537
spec:
3638
template:
3739
metadata:
@@ -51,18 +53,44 @@ spec:
5153
- bash
5254
- -c
5355
- |
56+
set -ex
5457
# Give the PVC a moment to fully mount
5558
echo "Waiting for PVC to be fully available..."
56-
sleep 5
59+
sleep 10
60+
61+
echo "Creating target directories if they don't exist..."
62+
mkdir -p /mnt/target/airflow-core
63+
mkdir -p /mnt/target/airflow-ctl
64+
mkdir -p /mnt/target/task-sdk
5765
5866
echo "Checking if development code directories exist..."
59-
# Check if the directories exist, but don't fail if they don't
60-
# We're just logging the status at this point
61-
cp -r {{ printf "%s/airflow-core" .Values.airflowHome }}/* /mnt/target/airflow-core || echo "copying airflow-core directory failed, it may not exist yet..."
62-
cp -r {{ printf "%s/airflow-ctl" .Values.airflowHome }}/* /mnt/target/airflow-ctl || echo "copying airflow-ctl directory failed, it may not exist yet..."
63-
cp -r {{ printf "%s/task-sdk" .Values.airflowHome }}/* /mnt/target/task-sdk || echo "copying task-sdk directory failed, it may not exist yet..."
67+
# Skip copying if source directories don't exist or are empty
68+
if [ -d "{{ printf "%s/airflow-core" .Values.airflowHome }}" ] && [ "$(ls -A {{ printf "%s/airflow-core" .Values.airflowHome }})" ]; then
69+
echo "Copying airflow-core files..."
70+
cp -rv {{ printf "%s/airflow-core" .Values.airflowHome }}/* /mnt/target/airflow-core/ || echo "Warning: Some files in airflow-core couldn't be copied"
71+
else
72+
echo "airflow-core directory doesn't exist or is empty, skipping..."
73+
touch /mnt/target/airflow-core/.placeholder
74+
fi
75+
76+
if [ -d "{{ printf "%s/airflow-ctl" .Values.airflowHome }}" ] && [ "$(ls -A {{ printf "%s/airflow-ctl" .Values.airflowHome }})" ]; then
77+
echo "Copying airflow-ctl files..."
78+
cp -rv {{ printf "%s/airflow-ctl" .Values.airflowHome }}/* /mnt/target/airflow-ctl/ || echo "Warning: Some files in airflow-ctl couldn't be copied"
79+
else
80+
echo "airflow-ctl directory doesn't exist or is empty, skipping..."
81+
touch /mnt/target/airflow-ctl/.placeholder
82+
fi
83+
84+
if [ -d "{{ printf "%s/task-sdk" .Values.airflowHome }}" ] && [ "$(ls -A {{ printf "%s/task-sdk" .Values.airflowHome }})" ]; then
85+
echo "Copying task-sdk files..."
86+
cp -rv {{ printf "%s/task-sdk" .Values.airflowHome }}/* /mnt/target/task-sdk/ || echo "Warning: Some files in task-sdk couldn't be copied"
87+
else
88+
echo "task-sdk directory doesn't exist or is empty, skipping..."
89+
touch /mnt/target/task-sdk/.placeholder
90+
fi
6491
6592
# List directories to verify they exist
93+
echo "Listing target directories content:"
6694
ls -la /mnt/target/airflow-core
6795
ls -la /mnt/target/airflow-ctl
6896
ls -la /mnt/target/task-sdk

0 commit comments

Comments
 (0)