Skip to content

Commit

Permalink
Fix default memory_limiter configuration for helm version 3.5.x
Browse files Browse the repository at this point in the history
Starting from helm 3.5.0, merging rules were changed: now if null value merged into a dict, null value is preserved.

In order to make it cleaner and working on all the versions, this commit replaces the merge operation with a conditional set.

If user wants to override the default memory_limiter configuration, they should override all the fields. That behavior seems more practical than partial override for the this processor.
  • Loading branch information
dmitryax committed Mar 22, 2021
1 parent 431e451 commit d508fe2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion charts/opentelemetry-collector/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ maintainers:
- name: pjanotti
- name: tigrannajaryan
icon: https://opentelemetry.io/img/logos/opentelemetry-logo-nav.png
appVersion: 0.22.0
appVersion: 0.22.1
25 changes: 13 additions & 12 deletions charts/opentelemetry-collector/templates/_config.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,28 @@
Default memory limiter configuration for OpenTelemetry Collector based on k8s resource limits.
*/}}
{{- define "opentelemetry-collector.memoryLimiter" -}}
processors:
memory_limiter:
# check_interval is the time between measurements of memory usage.
check_interval: 5s
# check_interval is the time between measurements of memory usage.
check_interval: 5s

# By default limit_mib is set to 80% of ".Values.resources.limits.memory"
limit_mib: {{ include "opentelemetry-collector.getMemLimitMib" .Values.resources.limits.memory }}
# By default limit_mib is set to 80% of ".Values.resources.limits.memory"
limit_mib: {{ include "opentelemetry-collector.getMemLimitMib" .Values.resources.limits.memory }}

# By default spike_limit_mib is set to 25% of ".Values.resources.limits.memory"
spike_limit_mib: {{ include "opentelemetry-collector.getMemSpikeLimitMib" .Values.resources.limits.memory }}
# By default spike_limit_mib is set to 25% of ".Values.resources.limits.memory"
spike_limit_mib: {{ include "opentelemetry-collector.getMemSpikeLimitMib" .Values.resources.limits.memory }}

# By default ballast_size_mib is set to 40% of ".Values.resources.limits.memory"
ballast_size_mib: {{ include "opentelemetry-collector.getMemBallastSizeMib" .Values.resources.limits.memory }}
# By default ballast_size_mib is set to 40% of ".Values.resources.limits.memory"
ballast_size_mib: {{ include "opentelemetry-collector.getMemBallastSizeMib" .Values.resources.limits.memory }}
{{- end }}

{{/*
Merge user supplied top-level (not particular to standalone or agent) config into memory limiter config.
*/}}
{{- define "opentelemetry-collector.baseConfig" -}}
{{- $config := include "opentelemetry-collector.memoryLimiter" . | fromYaml -}}
{{- .Values.config | mustMergeOverwrite $config | toYaml }}
{{- $processorsConfig := get .Values.config "processors" }}
{{- if not $processorsConfig.memory_limiter }}
{{- $_ := set $processorsConfig "memory_limiter" (include "opentelemetry-collector.memoryLimiter" . | fromYaml) }}
{{- end }}
{{- .Values.config | toYaml }}
{{- end }}

{{/*
Expand Down

0 comments on commit d508fe2

Please sign in to comment.