Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions charts/hdx-oss-v2/templates/hyperdx-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ spec:
- name: wait-for-mongodb
image: busybox
command: ['sh', '-c', 'until nc -z {{ include "hdx-oss.fullname" . }}-mongodb {{ .Values.mongodb.port }}; do echo waiting for mongodb; sleep 2; done;']
{{- if .Values.hyperdx.initContainers.resources }}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There were a lot of test failures from this PR. It's stemming from this line when an initContainer isn't defined. The target of the resources property lookup is null and this crashes.

There is a function called dig that can provide safe access to nested properties while handling null values safely.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you -- opted for hasKey for simplicity, and since there's no meaningful default value that I need if key isn't present. WDYT?

resources:
{{- toYaml .Values.hyperdx.initContainers.resources | nindent 12 }}
{{- end }}
{{- end }}
containers:
- name: app
Expand Down
34 changes: 33 additions & 1 deletion charts/hdx-oss-v2/tests/hyperdx-deployment_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -269,4 +269,36 @@ tests:
value: private-registry-secret
- lengthEqual:
path: spec.template.spec.imagePullSecrets
count: 3
count: 3

- it: should include initContainers resources when configured and mongodb is enabled
set:
mongodb:
enabled: true
hyperdx:
initContainers:
resources:
limits:
cpu: 1
memory: 1Gi
requests:
cpu: 2
memory: 2Gi
asserts:
- isNotEmpty:
path: spec.template.spec.initContainers
- equal:
path: spec.template.spec.initContainers[0].name
value: wait-for-mongodb
- isNotEmpty:
path: spec.template.spec.initContainers[0].resources
- equal:
path: spec.template.spec.initContainers[0].resources.limits
content:
cpu: 1
memory: 1Gi
- equal:
path: spec.template.spec.initContainers[0].resources.requests
content:
cpu: 2
memory: 2Gi
Loading