|
| 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 }} |
0 commit comments