jedcunningham commented on code in PR #31066:
URL: https://github.com/apache/airflow/pull/31066#discussion_r1237273886
##########
chart/INSTALL:
##########
Review Comment:
This should be in a newsfragment instead. I think we can keep a note about
using `useStandardNaming` in this file though.
##########
chart/templates/secrets/redis-secrets.yaml:
##########
Review Comment:
Same story with these, pre-upgrade isn't safe to add.
##########
chart/templates/secrets/fernetkey-secret.yaml:
##########
@@ -35,7 +35,7 @@ metadata:
{{- toYaml . | nindent 4 }}
{{- end }}
annotations:
- "helm.sh/hook": "pre-install"
+ "helm.sh/hook": "pre-install,pre-upgrade"
Review Comment:
This change isn't safe unfortunately. If users use the default generated
fernet key, it'll be changed during every helm upgrade.
##########
chart/templates/webserver/webserver-ingress.yaml:
##########
@@ -65,6 +65,7 @@ spec:
{{- .Values.ingress.web.hosts | default (list
.Values.ingress.web.host) | toYaml | nindent 8 }}
secretName: {{ .Values.ingress.web.tls.secretName }}
{{- end }}
+ {{- $fullname := (include "airflow.fullname" .) }}
Review Comment:
nit: should we just use this fullname variable for the ingress name as well?
##########
chart/templates/_helpers.yaml:
##########
@@ -23,7 +23,40 @@ We truncate at 63 chars because some Kubernetes name fields
are limited to this
If release name contains chart name it will be used as a full name.
*/}}
{{- define "airflow.fullname" -}}
- {{- if .Values.fullnameOverride }}
+ {{- if not .Values.useStandardNaming }}
+ {{- .Release.Name }}
+ {{- else if .Values.fullnameOverride }}
+ {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
+ {{- else }}
+ {{- $name := default .Chart.Name .Values.nameOverride }}
+ {{- if contains $name .Release.Name }}
+ {{- .Release.Name | trunc 63 | trimSuffix "-" }}
+ {{- else }}
+ {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
+ {{- end }}
+ {{- end }}
+{{- end }}
+
+{{/*
+Create a default fully qualified app name for objects that already contained
airflow in the name
+We truncate at 63 chars because some Kubernetes name fields are limited to
this (by the DNS naming spec).
+If release name contains chart name it will be used as a full name.
+*/}}
+{{- define "airflow.name" -}}
+ {{ if .Values.fullnameOverride }}
+ {{- printf "%s" .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
+ {{- else }}
+ {{- $name := default .Chart.Name .Values.nameOverride }}
+ {{- if contains $name .Release.Name }}
+ {{- .Release.Name | trunc 63 | trimSuffix "-" }}
+ {{- else }}
+ {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
Review Comment:
```suggestion
{{- printf "%s-airflow-%s" .Release.Name $name | trunc 63 | trimSuffix
"-" }}
```
Did you intend to do this so the `airflow` part remains? Otherwise, I don't
think we need to keep this. I think all of the old objects with "airflow" in
the name can be renamed safely.
##########
tests/charts/airflow_aux/test_basic_helm_chart.py:
##########
@@ -116,6 +116,49 @@ def test_basic_deployments(self, version):
"test-label"
), f"Missing label test-label on {k8s_name}. Current labels:
{labels}"
+ def test_basic_deployments_with_standard_naming(self):
+ k8s_objects = render_chart(
+ "test-basic",
+ {"useStandardNaming": True},
+ )
+ list_of_kind_names_tuples = {
+ (k8s_object["kind"], k8s_object["metadata"]["name"]) for
k8s_object in k8s_objects
+ }
+ expected = {
+ ("ServiceAccount", "test-basic-airflow-create-user-job"),
+ ("ServiceAccount", "test-basic-airflow-migrate-database-job"),
+ ("ServiceAccount", "test-basic-airflow-redis"),
+ ("ServiceAccount", "test-basic-airflow-scheduler"),
+ ("ServiceAccount", "test-basic-airflow-statsd"),
+ ("ServiceAccount", "test-basic-airflow-triggerer"),
+ ("ServiceAccount", "test-basic-airflow-webserver"),
+ ("ServiceAccount", "test-basic-airflow-worker"),
+ ("Secret", "test-basic-airflow-metadata"),
+ ("Secret", "test-basic-airflow-broker-url"),
+ ("Secret", "test-basic-airflow-fernet-key"),
+ ("Secret", "test-basic-airflow-webserver-secret-key"),
+ ("Secret", "test-basic-airflow-redis-password"),
+ ("ConfigMap", "test-basic-airflow-config"),
+ ("ConfigMap", "test-basic-airflow-statsd"),
+ ("Role", "test-basic-airflow-pod-launcher-role"),
+ ("Role", "test-basic-airflow-pod-log-reader-role"),
+ ("RoleBinding", "test-basic-airflow-pod-launcher-rolebinding"),
+ ("RoleBinding", "test-basic-airflow-pod-log-reader-rolebinding"),
+ ("Service", "test-basic-airflow-redis"),
+ ("Service", "test-basic-airflow-statsd"),
+ ("Service", "test-basic-airflow-webserver"),
+ ("Service", "test-basic-airflow-worker"),
+ ("Deployment", "test-basic-airflow-scheduler"),
+ ("Deployment", "test-basic-airflow-statsd"),
+ ("Deployment", "test-basic-airflow-webserver"),
+ ("StatefulSet", "test-basic-airflow-redis"),
+ ("StatefulSet", "test-basic-airflow-worker"),
+ ("Job", "test-basic-airflow-create-user"),
+ ("Job", "test-basic-airflow-run-airflow-migrations"),
+ }
+ for kind_name in expected:
+ assert kind_name in list_of_kind_names_tuples
Review Comment:
```suggestion
assert list_of_kind_names_tuples == expected
```
This feels like a better way to check? Makes sure we don't miss any new
additions.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]