Skip to content

Commit 75c0cd7

Browse files
committed
Add pre-install hook for dev mode code mount
1 parent f7a10e9 commit 75c0cd7

File tree

2 files changed

+95
-4
lines changed

2 files changed

+95
-4
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
{{/*
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
*/}}
19+
20+
{{- if .Values.devMode.enabled }}
21+
apiVersion: batch/v1
22+
kind: Job
23+
metadata:
24+
name: {{ .Release.Name }}-init-dev-code
25+
labels:
26+
tier: airflow
27+
component: init-dev-code
28+
release: {{ .Release.Name }}
29+
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
30+
heritage: {{ .Release.Service }}
31+
annotations:
32+
helm.sh/hook: "pre-install"
33+
helm.sh/hook-weight: "5"
34+
# helm.sh/hook-delete-policy: hook-succeeded
35+
spec:
36+
template:
37+
metadata:
38+
labels:
39+
tier: airflow
40+
component: init-dev-code
41+
release: {{ .Release.Name }}
42+
spec:
43+
securityContext: {{ include "airflowPodSecurityContext" (list . .Values) | nindent 8 }}
44+
restartPolicy: OnFailure
45+
containers:
46+
- name: init-dev-code
47+
image: {{ template "airflow_image" . }}
48+
imagePullPolicy: {{ .Values.images.airflow.pullPolicy }}
49+
securityContext: {{ include "containerSecurityContext" (list . .Values) | nindent 12 }}
50+
command:
51+
- bash
52+
- -c
53+
- |
54+
# Give the PVC a moment to fully mount
55+
echo "Waiting for PVC to be fully available..."
56+
sleep 5
57+
58+
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..."
64+
65+
# List directories to verify they exist
66+
ls -la /mnt/target/airflow-core
67+
ls -la /mnt/target/airflow-ctl
68+
ls -la /mnt/target/task-sdk
69+
70+
# Add a marker file to indicate this job has run
71+
touch {{ printf "%s/airflow-core/.init-complete" .Values.airflowHome }}
72+
73+
echo "All required development code directories verified or created."
74+
volumeMounts:
75+
- name: code
76+
mountPath: /mnt/target/airflow-core
77+
subPath: airflow-core
78+
- name: code
79+
mountPath: /mnt/target/airflow-ctl
80+
subPath: airflow-ctl
81+
- name: code
82+
mountPath: /mnt/target/task-sdk
83+
subPath: task-sdk
84+
volumes:
85+
- name: code
86+
persistentVolumeClaim:
87+
claimName: {{ template "airflow_code_volume_claim" . }}
88+
{{- end }}

chart/templates/airflow-code-volume-claim.yaml renamed to chart/templates/dev-mode-code-volume-claim.yaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,14 @@ metadata:
3434
{{- with .Values.labels }}
3535
{{- toYaml . | nindent 4 }}
3636
{{- end }}
37-
{{- with .Values.devMode.persistence.annotations }}
38-
annotations: {{- toYaml . | nindent 4 }}
39-
{{- end }}
37+
annotations:
38+
helm.sh/hook: "pre-install"
39+
helm.sh/hook-weight: "-10"
40+
{{- with .Values.devMode.persistence.annotations }}
41+
{{- toYaml . | nindent 4 }}
42+
{{- end }}
4043
spec:
41-
accessModes: ["ReadOnlyMany"]
44+
accessModes: ["ReadWriteOnce"]
4245
resources:
4346
requests:
4447
storage: {{ .Values.devMode.persistence.size | quote }}

0 commit comments

Comments
 (0)