-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
segregate resource strategy Migration Job (#2124)
* fix pre-commit * update migration job * add test cases
- Loading branch information
1 parent
fa99126
commit 3c622d5
Showing
3 changed files
with
92 additions
and
1 deletion.
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
charts/astronomer/templates/houston/helm-hooks/houston-au-strategy-job.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
####################################### | ||
## Resource Strategy Migration Job | ||
####################################### | ||
apiVersion: {{ include "apiVersion.batch" . }} | ||
kind: Job | ||
metadata: | ||
name: {{ .Release.Name }}-update-resource-strategy | ||
labels: | ||
tier: astronomer | ||
component: houston-update-resource-strategy | ||
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" | ||
release: {{ .Release.Name }} | ||
heritage: {{ .Release.Service }} | ||
annotations: | ||
# This is what defines this resource as a hook. Without this line, the | ||
# job is considered part of the release. | ||
"helm.sh/hook": post-upgrade,post-install | ||
# since weight is larger than db migration job we should not need the wait for db init container | ||
"helm.sh/hook-weight": "1" | ||
"helm.sh/hook-delete-policy": before-hook-creation | ||
spec: | ||
completions: 1 | ||
parallelism: 1 | ||
backoffLimit: 1 | ||
template: | ||
metadata: | ||
labels: | ||
tier: astronomer | ||
component: houston-update-resource-strategy | ||
release: {{ .Release.Name }} | ||
app: houston-update-resource-strategy | ||
version: {{ .Chart.Version }} | ||
{{- if .Values.global.istio.enabled }} | ||
annotations: | ||
sidecar.istio.io/inject: "false" | ||
{{- end }} | ||
spec: | ||
serviceAccountName: {{ template "houston.bootstrapperServiceAccount" . }} | ||
nodeSelector: | ||
{{ toYaml (default .Values.global.platformNodePool.nodeSelector .Values.nodeSelector) | indent 8 }} | ||
affinity: | ||
{{ toYaml (default .Values.global.platformNodePool.affinity .Values.affinity) | indent 8 }} | ||
tolerations: | ||
{{ toYaml (default .Values.global.platformNodePool.tolerations .Values.tolerations) | indent 8 }} | ||
restartPolicy: Never | ||
{{- include "astronomer.imagePullSecrets" . | indent 6 }} | ||
containers: | ||
- name: post-upgrade-update-resource-strategy | ||
image: {{ template "houston.image" . }} | ||
imagePullPolicy: {{ .Values.images.houston.pullPolicy }} | ||
command: ["yarn"] | ||
# If you supply only args for a Container, the default Entrypoint defined in the Docker image is run with the args that you supplied. | ||
args: ["update-deployments-resource-mode"] | ||
volumeMounts: | ||
{{- include "houston_volume_mounts" . | indent 12 }} | ||
{{- include "custom_ca_volume_mounts" . | indent 12 }} | ||
env: | ||
- name: DATABASE_URL | ||
valueFrom: | ||
secretKeyRef: | ||
name: {{ template "houston.backendSecret" . }} | ||
key: connection | ||
volumes: | ||
{{- include "houston_volumes" . | indent 8 }} | ||
{{- include "custom_ca_volumes" . | indent 8 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import pytest | ||
from tests import supported_k8s_versions | ||
from tests.chart_tests.helm_template_generator import render_chart | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"kube_version", | ||
supported_k8s_versions, | ||
) | ||
class TestHoustonHookJob: | ||
def test_au_strategy_job_defaults(self, kube_version): | ||
"""Test AU Strategy Job defaults.""" | ||
docs = render_chart( | ||
kube_version=kube_version, | ||
values={}, | ||
show_only=[ | ||
"charts/astronomer/templates/houston/helm-hooks/houston-au-strategy-job.yaml" | ||
], | ||
) | ||
assert len(docs) == 1 | ||
assert docs[0]["kind"] == "Job" | ||
assert docs[0]["metadata"]["name"] == "release-name-update-resource-strategy" | ||
|
||
assert docs[0]["spec"]["template"]["spec"]["containers"][0]["args"] == [ | ||
"update-deployments-resource-mode" | ||
] |