Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions app/functions/helmless/default-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1749,6 +1749,12 @@ aggregator:
# Whether to enable the emptyDir volume for the aggregator.
enabled: true
# Size limit for the emptyDir volume. If not set, no limit is applied.
#
# When set, this is also used as the collector container's
# ephemeral-storage request, so the pod is only scheduled onto a node
# with enough allocatable ephemeral storage. Set
# components.aggregator.collector.resources.requests.ephemeral-storage
# to override it.
sizeLimit: ""
# Configuration for the collector component of the aggregator.
collector:
Expand Down
29 changes: 8 additions & 21 deletions helm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -1345,28 +1345,15 @@ Example usage:
{{- if . -}}
{{- $resources := . -}}
{{- $cleanResources := dict -}}
{{- if $resources.requests -}}
{{- $cleanRequests := dict -}}
{{- if and $resources.requests.cpu (ne $resources.requests.cpu "") -}}
{{- $_ := set $cleanRequests "cpu" $resources.requests.cpu -}}
{{- end -}}
{{- if and $resources.requests.memory (ne $resources.requests.memory "") -}}
{{- $_ := set $cleanRequests "memory" $resources.requests.memory -}}
{{- end -}}
{{- if $cleanRequests -}}
{{- $_ := set $cleanResources "requests" $cleanRequests -}}
{{- end -}}
{{- end -}}
{{- if $resources.limits -}}
{{- $cleanLimits := dict -}}
{{- if and $resources.limits.cpu (ne $resources.limits.cpu "") -}}
{{- $_ := set $cleanLimits "cpu" $resources.limits.cpu -}}
{{- end -}}
{{- if and $resources.limits.memory (ne $resources.limits.memory "") -}}
{{- $_ := set $cleanLimits "memory" $resources.limits.memory -}}
{{- range $section := list "requests" "limits" -}}
{{- $clean := dict -}}
{{- range $name, $value := (index $resources $section | default dict) -}}
{{- if and $value (ne (toString $value) "") -}}
{{- $_ := set $clean $name $value -}}
{{- end -}}
{{- end -}}
{{- if $cleanLimits -}}
{{- $_ := set $cleanResources "limits" $cleanLimits -}}
{{- if $clean -}}
{{- $_ := set $cleanResources $section $clean -}}
{{- end -}}
{{- end -}}
{{- if $cleanResources -}}
Expand Down
18 changes: 16 additions & 2 deletions helm/templates/aggregator-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,24 @@ spec:
initialDelaySeconds: {{ $collectorLiveness.initialDelaySeconds }}
periodSeconds: {{ $collectorLiveness.periodSeconds }}
failureThreshold: {{ $collectorLiveness.failureThreshold }}
{{- include "cloudzero-agent.generateResources" (include "cloudzero-agent.mergeStringOverwrite" (list
{{- $collectorResources := include "cloudzero-agent.mergeStringOverwrite" (list
(.Values.components.aggregator.collector.resources | default (dict))
(.Values.aggregator.collector.resources | default (dict))
) | fromYaml) | nindent 10 }}
) | fromYaml -}}
{{- /*
The collector writes the metric files to the shared emptyDir, so when a
sizeLimit is set, reserve that much ephemeral storage for scheduling
unless the collector requests ephemeral storage explicitly.
*/}}
{{- $emptyDir := .Values.aggregator.database.emptyDir }}
{{- if and $emptyDir.enabled $emptyDir.sizeLimit }}
{{- $requests := $collectorResources.requests | default (dict) }}
{{- if not (index $requests "ephemeral-storage") }}
{{- $_ := set $requests "ephemeral-storage" $emptyDir.sizeLimit }}
{{- $_ := set $collectorResources "requests" $requests }}
Comment thread
evan-cz marked this conversation as resolved.
{{- end }}
{{- end }}
{{- include "cloudzero-agent.generateResources" $collectorResources | nindent 10 }}
{{- include "cloudzero-agent.generateContainerSecurityContext" (mergeOverwrite
(.Values.defaults.securityContext | default (dict))
(.Values.aggregator.collector.securityContext | default (dict))
Expand Down
51 changes: 51 additions & 0 deletions helm/tests/aggregator_resources_fallback_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,54 @@ tests:
- equal:
path: spec.template.spec.containers[0].resources.limits.cpu
value: "4000m"

- it: should render ephemeral-storage requests and limits
set:
components.aggregator.collector.resources:
requests:
ephemeral-storage: "1Gi"
limits:
ephemeral-storage: "2Gi"
asserts:
- equal:
path: spec.template.spec.containers[0].resources.requests.ephemeral-storage
value: "1Gi"
- equal:
path: spec.template.spec.containers[0].resources.limits.ephemeral-storage
value: "2Gi"

- it: should request the emptyDir sizeLimit as collector ephemeral-storage
set:
aggregator.database.emptyDir.sizeLimit: "5Gi"
asserts:
- equal:
path: spec.template.spec.containers[0].resources.requests.ephemeral-storage
value: "5Gi"
- notExists:
path: spec.template.spec.containers[0].resources.limits.ephemeral-storage
- notExists:
path: spec.template.spec.containers[1].resources.requests.ephemeral-storage

- it: should prefer an explicit collector ephemeral-storage request over the sizeLimit
set:
aggregator.database.emptyDir.sizeLimit: "5Gi"
components.aggregator.collector.resources:
requests:
ephemeral-storage: "1Gi"
asserts:
- equal:
path: spec.template.spec.containers[0].resources.requests.ephemeral-storage
value: "1Gi"

- it: should not request ephemeral-storage when no sizeLimit is set
asserts:
- notExists:
path: spec.template.spec.containers[0].resources.requests.ephemeral-storage

- it: should not request ephemeral-storage when the emptyDir is disabled
set:
aggregator.database.emptyDir.enabled: false
aggregator.database.emptyDir.sizeLimit: "5Gi"
asserts:
- notExists:
path: spec.template.spec.containers[0].resources.requests.ephemeral-storage
6 changes: 6 additions & 0 deletions helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1749,6 +1749,12 @@ aggregator:
# Whether to enable the emptyDir volume for the aggregator.
enabled: true
# Size limit for the emptyDir volume. If not set, no limit is applied.
#
# When set, this is also used as the collector container's
# ephemeral-storage request, so the pod is only scheduled onto a node
# with enough allocatable ephemeral storage. Set
# components.aggregator.collector.resources.requests.ephemeral-storage
# to override it.
sizeLimit: ""
# Configuration for the collector component of the aggregator.
collector:
Expand Down
Loading