Skip to content

Commit

Permalink
segregate resource strategy Migration Job (#2124)
Browse files Browse the repository at this point in the history
* fix pre-commit

* update migration job

* add test cases
  • Loading branch information
pgvishnuram committed Feb 9, 2024
1 parent fa99126 commit 3c622d5
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 1 deletion.
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 }}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ metadata:
annotations:
# This is what defines this resource as a hook. Without this line, the
# job is considered part of the release.
"helm.sh/hook": pre-upgrade,post-upgrade,post-install
"helm.sh/hook": pre-upgrade,post-install
"helm.sh/hook-delete-policy": before-hook-creation
spec:
template:
Expand Down
26 changes: 26 additions & 0 deletions tests/chart_tests/test_astronomer_houston_hook_job.py
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"
]

0 comments on commit 3c622d5

Please sign in to comment.