Skip to content

Commit

Permalink
extract probe path from AIRFLOW__WEBSERVER__BASE_URL + ingress path v…
Browse files Browse the repository at this point in the history
…alidation (#120)

* extract liveness and readiness path for web container from airflow config setting

Signed-off-by: bensta <9579702+bensta@users.noreply.github.com>

* improve validation for ingress path values

Signed-off-by: Mathew Wicks <thesuperzapper@users.noreply.github.com>

* bump chart version

Signed-off-by: Mathew Wicks <thesuperzapper@users.noreply.github.com>
  • Loading branch information
bensta authored Apr 5, 2021
1 parent 65d850e commit f45f453
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion charts/airflow/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
description: airflow is a platform to programmatically author, schedule, and monitor workflows
name: airflow
version: 8.0.4
version: 8.0.5
appVersion: 2.0.1
icon: https://airflow.apache.org/_images/pin_large.png
home: https://airflow.apache.org/
Expand Down
12 changes: 11 additions & 1 deletion charts/airflow/templates/_helpers/validate-values.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@
{{- if .Values.ingress.web.path | hasSuffix "/" }}
{{ required "The `ingress.web.path` should NOT include a trailing '/'!" nil }}
{{- end }}
{{- if .Values.airflow.config.AIRFLOW__WEBSERVER__BASE_URL }}
{{- $webUrl := .Values.airflow.config.AIRFLOW__WEBSERVER__BASE_URL | urlParse }}
{{- if not (eq .Values.ingress.web.path (get $webUrl "path")) }}
{{ required (printf "The `ingress.web.path` must be compatable with `airflow.config.AIRFLOW__WEBSERVER__BASE_URL`! (try setting AIRFLOW__WEBSERVER__BASE_URL to 'http://{HOSTNAME}%s', rather than '%s')" .Values.ingress.web.path .Values.airflow.config.AIRFLOW__WEBSERVER__BASE_URL) nil }}
{{- end }}
{{- else }}
{{ required (printf "If `ingress.web.path` is set, then `airflow.config.AIRFLOW__WEBSERVER__BASE_URL` must be set! (try setting AIRFLOW__WEBSERVER__BASE_URL to 'http://{HOSTNAME}%s')" .Values.ingress.web.path) nil }}
{{- end }}
{{- end }}

{{/* Checks for `ingress.flower.path` */}}
Expand All @@ -85,8 +93,10 @@
{{- end }}
{{- if .Values.airflow.config.AIRFLOW__CELERY__FLOWER_URL_PREFIX }}
{{- if not (eq .Values.ingress.flower.path .Values.airflow.config.AIRFLOW__CELERY__FLOWER_URL_PREFIX) }}
{{ required "The `ingress.flower.path` should be the same as `airflow.config.AIRFLOW__CELERY__FLOWER_URL_PREFIX`!" nil }}
{{ required (printf "The `ingress.flower.path` must be compatable with `airflow.config.AIRFLOW__CELERY__FLOWER_URL_PREFIX`! (try setting AIRFLOW__CELERY__FLOWER_URL_PREFIX to '%s', rather than '%s')" .Values.ingress.flower.path .Values.airflow.config.AIRFLOW__CELERY__FLOWER_URL_PREFIX) nil }}
{{- end }}
{{- else }}
{{ required (printf "If `ingress.flower.path` is set, then `airflow.config.AIRFLOW__CELERY__FLOWER_URL_PREFIX` must be set! (try setting AIRFLOW__CELERY__FLOWER_URL_PREFIX to '%s')" .Values.ingress.flower.path) nil }}
{{- end }}
{{- end }}
{{- end }}
5 changes: 0 additions & 5 deletions charts/airflow/templates/config/secret-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,6 @@ stringData:
AIRFLOW__SCHEDULER__DAG_DIR_LIST_INTERVAL: {{ .Values.dags.gitSync.syncWait | quote }}
{{- end }}

{{- if and (.Values.ingress.enabled) (.Values.ingress.flower.path) (not .Values.airflow.config.AIRFLOW__CELERY__FLOWER_URL_PREFIX) }}
## ensuring the ingress path is aligned with flower URL prefix
AIRFLOW__CELERY__FLOWER_URL_PREFIX: {{ .Values.ingress.flower.path | quote }}
{{- end }}

{{- if .Values.airflow.legacyCommands }}
{{- if not .Values.airflow.config.AIRFLOW__WEBSERVER__RBAC }}
## default to the RBAC UI when in legacy mode
Expand Down
6 changes: 4 additions & 2 deletions charts/airflow/templates/webserver/webserver-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ spec:
failureThreshold: {{ .Values.web.livenessProbe.failureThreshold }}
httpGet:
scheme: {{ include "airflow.web.scheme" . }}
path: "/health"
{{- $airflowUrl := .Values.airflow.config.AIRFLOW__WEBSERVER__BASE_URL | default "" | printf "%s/health" | urlParse }}
path: {{ get $airflowUrl "path" }}
port: web
{{- end }}
{{- if .Values.web.readinessProbe.enabled }}
Expand All @@ -122,7 +123,8 @@ spec:
failureThreshold: {{ .Values.web.readinessProbe.failureThreshold }}
httpGet:
scheme: {{ include "airflow.web.scheme" . }}
path: "/health"
{{- $airflowUrl := .Values.airflow.config.AIRFLOW__WEBSERVER__BASE_URL | default "" | printf "%s/health" | urlParse }}
path: {{ get $airflowUrl "path" }}
port: web
{{- end }}
{{- $extraVolumeMounts := .Values.web.extraVolumeMounts }}
Expand Down

0 comments on commit f45f453

Please sign in to comment.