Skip to content

Commit dcbd8ae

Browse files
committed
Add startupProbe for git-sync
1 parent 16ee44c commit dcbd8ae

5 files changed

Lines changed: 136 additions & 0 deletions

File tree

chart/templates/_helpers.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,11 +318,26 @@ If release name contains chart name it will be used as a full name.
318318
value: "true"
319319
- name: GITSYNC_ONE_TIME
320320
value: "true"
321+
{{- else }}
322+
- name: GIT_SYNC_HTTP_BIND
323+
value: ":{{ .Values.dags.gitSync.startupProbe.port }}"
324+
- name: GITSYNC_HTTP_BIND
325+
value: ":{{ .Values.dags.gitSync.startupProbe.port }}"
321326
{{- end }}
322327
{{- with .Values.dags.gitSync.env }}
323328
{{- toYaml . | nindent 4 }}
324329
{{- end }}
325330
resources: {{ toYaml .Values.dags.gitSync.resources | nindent 4 }}
331+
{{- if and .Values.dags.gitSync.startupProbe.enabled (not .is_init) }}
332+
startupProbe:
333+
httpGet:
334+
path: /
335+
port: {{ .Values.dags.gitSync.startupProbe.port }}
336+
timeoutSeconds: {{ .Values.dags.gitSync.startupProbe.timeoutSeconds }}
337+
initialDelaySeconds: {{ .Values.dags.gitSync.startupProbe.initialDelaySeconds }}
338+
periodSeconds: {{ .Values.dags.gitSync.startupProbe.periodSeconds }}
339+
failureThreshold: {{ .Values.dags.gitSync.startupProbe.failureThreshold }}
340+
{{- end }}
326341
{{- if and .Values.dags.gitSync.livenessProbe (not .is_init) }}
327342
livenessProbe: {{ tpl (toYaml .Values.dags.gitSync.livenessProbe) . | nindent 4 }}
328343
{{- end }}

chart/values.schema.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10302,6 +10302,43 @@
1030210302
}
1030310303
]
1030410304
},
10305+
"startupProbe": {
10306+
"description": "Startup probe configuration for GitSync container.",
10307+
"type": "object",
10308+
"additionalProperties": false,
10309+
"properties": {
10310+
"enabled": {
10311+
"description": "Enable GitSync Kubernetes Startup Probe.",
10312+
"type": "boolean",
10313+
"default": true
10314+
},
10315+
"port": {
10316+
"description": "Port used for Git Sync liveness listener configuration.",
10317+
"type": "integer",
10318+
"default": 1234
10319+
},
10320+
"timeoutSeconds": {
10321+
"description": "Number of seconds after which the probe times out. Minimum value is 1 seconds.",
10322+
"type": "integer",
10323+
"default": 1
10324+
},
10325+
"initialDelaySeconds": {
10326+
"description": "Number of seconds after the container has started before startup probe is initiated.",
10327+
"type": "integer",
10328+
"default": 0
10329+
},
10330+
"periodSeconds": {
10331+
"description": "How often (in seconds) to perform the probe. Minimum value is 1.",
10332+
"type": "integer",
10333+
"default": 5
10334+
},
10335+
"failureThreshold": {
10336+
"description": "Minimum consecutive failures for the probe to be considered failed after having succeeded. Minimum value is 1.",
10337+
"type": "integer",
10338+
"default": 10
10339+
}
10340+
}
10341+
},
1030510342
"livenessProbe": {
1030610343
"description": "Liveness probe configuration for git sync container.",
1030710344
"type": "object",

chart/values.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3527,6 +3527,14 @@ dags:
35273527
# container level lifecycle hooks
35283528
containerLifecycleHooks: {}
35293529

3530+
startupProbe:
3531+
enabled: true
3532+
port: 1234
3533+
timeoutSeconds: 1
3534+
initialDelaySeconds: 0
3535+
periodSeconds: 5
3536+
failureThreshold: 10
3537+
35303538
readinessProbe: {}
35313539
livenessProbe: {}
35323540

helm-tests/tests/helm_tests/airflow_aux/test_airflow_common.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,64 @@ def test_dags_mount(self, dag_values, expected_mount):
147147
for doc in docs:
148148
assert expected_mount in jmespath.search("spec.template.spec.containers[0].volumeMounts", doc)
149149

150+
def test_git_sync_startup_probe_enabled(self):
151+
docs = render_chart(
152+
values={
153+
"dags": {"gitSync": {"enabled": True, "startupProbe": {"enabled": False}}},
154+
},
155+
show_only=[
156+
"templates/dag-processor/dag-processor-deployment.yaml",
157+
"templates/triggerer/triggerer-deployment.yaml",
158+
"templates/workers/worker-deployment.yaml",
159+
],
160+
)
161+
162+
assert len(docs) == 3
163+
for doc in docs:
164+
assert (
165+
jmespath.search("spec.template.spec.containers[?name=='git-sync'] | [0].startupProbe", doc)
166+
is None
167+
)
168+
169+
def test_git_sync_startup_probe(self):
170+
docs = render_chart(
171+
values={
172+
"dags": {
173+
"gitSync": {
174+
"enabled": True,
175+
"startupProbe": {
176+
"port": 10,
177+
"timeoutSeconds": 11,
178+
"initialDelaySeconds": 12,
179+
"periodSeconds": 13,
180+
"failureThreshold": 14,
181+
},
182+
}
183+
},
184+
},
185+
show_only=[
186+
"templates/dag-processor/dag-processor-deployment.yaml",
187+
"templates/triggerer/triggerer-deployment.yaml",
188+
"templates/workers/worker-deployment.yaml",
189+
],
190+
)
191+
192+
assert len(docs) == 3
193+
for doc in docs:
194+
envs = jmespath.search("spec.template.spec.containers[?name=='git-sync'] | [0].env", doc)
195+
assert {"name": "GIT_SYNC_HTTP_BIND", "value": ":10"} in envs
196+
assert {"name": "GITSYNC_HTTP_BIND", "value": ":10"} in envs
197+
198+
assert jmespath.search(
199+
"spec.template.spec.containers[?name=='git-sync'] | [0].startupProbe", doc
200+
) == {
201+
"httpGet": {"path": "/", "port": 10},
202+
"timeoutSeconds": 11,
203+
"initialDelaySeconds": 12,
204+
"periodSeconds": 13,
205+
"failureThreshold": 14,
206+
}
207+
150208
def test_webserver_config_configmap_name_volume_mounts(self):
151209
configmap_name = "my-configmap"
152210
docs = render_chart(

helm-tests/tests/helm_tests/other/test_git_sync_scheduler.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,18 @@ def test_validate_the_git_sync_container_spec(self):
108108
{"name": "GITSYNC_PERIOD", "value": "66s"},
109109
{"name": "GIT_SYNC_MAX_SYNC_FAILURES", "value": "70"},
110110
{"name": "GITSYNC_MAX_FAILURES", "value": "70"},
111+
{"name": "GIT_SYNC_HTTP_BIND", "value": ":1234"},
112+
{"name": "GITSYNC_HTTP_BIND", "value": ":1234"},
111113
],
112114
"volumeMounts": [{"mountPath": "/git", "name": "dags"}],
113115
"resources": {},
116+
"startupProbe": {
117+
"httpGet": {"path": "/", "port": 1234},
118+
"timeoutSeconds": 1,
119+
"failureThreshold": 10,
120+
"initialDelaySeconds": 0,
121+
"periodSeconds": 5,
122+
},
114123
}
115124

116125
def test_validate_the_git_sync_container_spec_if_wait_specified(self):
@@ -172,9 +181,18 @@ def test_validate_the_git_sync_container_spec_if_wait_specified(self):
172181
{"name": "GITSYNC_PERIOD", "value": "66s"},
173182
{"name": "GIT_SYNC_MAX_SYNC_FAILURES", "value": "70"},
174183
{"name": "GITSYNC_MAX_FAILURES", "value": "70"},
184+
{"name": "GIT_SYNC_HTTP_BIND", "value": ":1234"},
185+
{"name": "GITSYNC_HTTP_BIND", "value": ":1234"},
175186
],
176187
"volumeMounts": [{"mountPath": "/git", "name": "dags"}],
177188
"resources": {},
189+
"startupProbe": {
190+
"httpGet": {"path": "/", "port": 1234},
191+
"timeoutSeconds": 1,
192+
"failureThreshold": 10,
193+
"initialDelaySeconds": 0,
194+
"periodSeconds": 5,
195+
},
178196
}
179197

180198
def test_validate_if_ssh_params_are_added(self):

0 commit comments

Comments
 (0)