Skip to content

Commit 3e18303

Browse files
authored
fix(alerts): update cronjob template to account for different code builds (#143)
In HyperDX 2.7.1, the way in which the typescript code is built and packaged changed, which changes the command required to start the cron job. This commit updates the template such that: * versions before 2.7.1 should continue to use the esbuild command to run the cron job. * versions 2.7.1+ or non-semver tags, e.g. 2-nightly) will use the updated non-esbuild command to run the job.
1 parent 80f3c03 commit 3e18303

File tree

3 files changed

+74
-4
lines changed

3 files changed

+74
-4
lines changed

.changeset/cuddly-papayas-give.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"helm-charts": patch
3+
---
4+
5+
Fixes the alert cron job template so newer version image tags will use the updated command to start the task.

charts/hdx-oss-v2/templates/cronjobs/task-checkAlerts.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ spec:
2626
- name: task
2727
image: "{{ .Values.hyperdx.image.repository }}:{{ .Values.hyperdx.image.tag | default .Chart.AppVersion }}"
2828
imagePullPolicy: {{ .Values.hyperdx.image.pullPolicy }}
29+
{{- $tag := .Values.hyperdx.image.tag | default .Chart.AppVersion -}}
30+
{{- if and (regexMatch "^[0-9]+\\.[0-9]+\\.[0-9]+" $tag) (semverCompare "< 2.7.1" $tag) }} # before esbuild revert
2931
command: ["node", "/app/packages/api/tasks/index", "check-alerts"]
32+
{{- else }}
33+
command: ["node", "/app/api/build/tasks/index.js", "check-alerts"] # after esbuild revert
34+
{{- end }}
3035
envFrom:
3136
- configMapRef:
3237
name: {{ include "hdx-oss.fullname" . }}-app-config

charts/hdx-oss-v2/tests/task-checkAlerts_test.yaml

Lines changed: 64 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ tests:
99
asserts:
1010
- hasDocuments:
1111
count: 0
12-
12+
1313
- it: should render correctly when tasks are enabled
1414
set:
1515
tasks:
@@ -24,7 +24,7 @@ tests:
2424
cpu: 150m
2525
memory: 150Mi
2626
hyperdx:
27-
image:
27+
image:
2828
repository: hyperdx/hyperdx
2929
tag: 2-beta
3030
asserts:
@@ -38,7 +38,7 @@ tests:
3838
value: hyperdx/hyperdx:2-beta
3939
- equal:
4040
path: spec.jobTemplate.spec.template.spec.containers[0].command
41-
value: ["node", "/app/packages/api/tasks/index", "check-alerts"]
41+
value: ["node", "/app/api/build/tasks/index.js", "check-alerts"]
4242
- isSubset:
4343
path: spec.jobTemplate.spec.template.spec.containers[0].resources
4444
content:
@@ -63,7 +63,7 @@ tests:
6363
content:
6464
name: OTEL_SERVICE_NAME
6565
value: "hdx-oss-task-check-alerts"
66-
66+
6767
- it: should use default schedule when not provided
6868
set:
6969
tasks:
@@ -94,3 +94,63 @@ tests:
9494
- equal:
9595
path: spec.jobTemplate.spec.template.spec.imagePullSecrets[0].name
9696
value: regcred
97+
98+
- it: should use esbuild command path for versions before 2.7.1
99+
set:
100+
tasks:
101+
enabled: true
102+
hyperdx:
103+
image:
104+
tag: "2.7.0"
105+
asserts:
106+
- equal:
107+
path: spec.jobTemplate.spec.template.spec.containers[0].command
108+
value: ["node", "/app/packages/api/tasks/index", "check-alerts"]
109+
110+
- it: should use esbuild command path for version 2.6.0
111+
set:
112+
tasks:
113+
enabled: true
114+
hyperdx:
115+
image:
116+
tag: "2.6.0"
117+
asserts:
118+
- equal:
119+
path: spec.jobTemplate.spec.template.spec.containers[0].command
120+
value: ["node", "/app/packages/api/tasks/index", "check-alerts"]
121+
122+
- it: should use post-esbuild command path for version 2.7.1
123+
set:
124+
tasks:
125+
enabled: true
126+
hyperdx:
127+
image:
128+
tag: "2.7.1"
129+
asserts:
130+
- equal:
131+
path: spec.jobTemplate.spec.template.spec.containers[0].command
132+
value: ["node", "/app/api/build/tasks/index.js", "check-alerts"]
133+
134+
- it: should use post-esbuild command path for versions after 2.7.1
135+
set:
136+
tasks:
137+
enabled: true
138+
hyperdx:
139+
image:
140+
tag: "2.8.0"
141+
asserts:
142+
- equal:
143+
path: spec.jobTemplate.spec.template.spec.containers[0].command
144+
value: ["node", "/app/api/build/tasks/index.js", "check-alerts"]
145+
146+
- it: should use post-esbuild command path for version 3.0.0
147+
set:
148+
tasks:
149+
enabled: true
150+
hyperdx:
151+
image:
152+
tag: "3.0.0"
153+
asserts:
154+
- equal:
155+
path: spec.jobTemplate.spec.template.spec.containers[0].command
156+
value: ["node", "/app/api/build/tasks/index.js", "check-alerts"]

0 commit comments

Comments
 (0)