Skip to content

Commit 6145317

Browse files
authored
Add useMemoryLimitPercentage feature gate (#1761)
Add `useMemoryLimitPercentage` feature gate that enables the use of the memory_limiter processor based on the percentage. It is required if the helm chart is used with another collector image from upstream.
1 parent 5f3a421 commit 6145317

File tree

7 files changed

+41
-3
lines changed

7 files changed

+41
-3
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
2+
change_type: enhancement
3+
# The name of the component, or a single word describing the area of concern, (e.g. agent, clusterReceiver, gateway, operator, chart, other)
4+
component: all
5+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
6+
note: Add useMemoryLimitPercentage feature gate
7+
# One or more tracking issues related to the change
8+
issues: [1761]

helm-charts/splunk-otel-collector/templates/_helpers.tpl

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,10 @@ Create the validateSecret image name.
228228
{{- end -}}
229229

230230
{{/*
231-
This helper converts the input value of memory to MiB.
231+
This helper converts the input value of memory to Bytes.
232232
Input needs to be a valid value as supported by k8s memory resource field.
233233
*/}}
234-
{{- define "splunk-otel-collector.convertMemToMib" }}
234+
{{- define "splunk-otel-collector.convertMemToBytes" }}
235235
{{- $mem := lower . -}}
236236
{{- if hasSuffix "e" $mem -}}
237237
{{- $mem = mulf (trimSuffix "e" $mem | float64) 1e18 -}}
@@ -258,7 +258,15 @@ Create the validateSecret image name.
258258
{{- else if hasSuffix "ki" $mem -}}
259259
{{- $mem = mulf (trimSuffix "ki" $mem | float64) 0x1p10 -}}
260260
{{- end }}
261-
{{- divf $mem 0x1p20 | floor -}}
261+
{{- $mem }}
262+
{{- end }}
263+
264+
{{/*
265+
This helper converts the input value of memory to MiB.
266+
Input needs to be a valid value as supported by k8s memory resource field.
267+
*/}}
268+
{{- define "splunk-otel-collector.convertMemToMib" }}
269+
{{- divf (include "splunk-otel-collector.convertMemToBytes" .) 0x1p20 | floor -}}
262270
{{- end }}
263271

264272
{{/*

helm-charts/splunk-otel-collector/templates/config/_common.tpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ memory_limiter:
66
# check_interval is the time between measurements of memory usage.
77
check_interval: 2s
88
# By default limit_mib is set to 90% of container memory limit
9+
{{- if .Values.featureGates.useMemoryLimitPercentage }}
10+
limit_percentage: 90
11+
{{- else }}
912
limit_mib: ${SPLUNK_MEMORY_LIMIT_MIB}
13+
{{- end }}
1014
{{- end }}
1115

1216
{{/*

helm-charts/splunk-otel-collector/templates/daemonset.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,13 @@ spec:
274274
{{- include "splunk-otel-collector.securityContext" (dict "isWindows" .Values.isWindows "securityContext" $agent.securityContext "setRunAsUser" true) | nindent 10 }}
275275
{{- end }}
276276
env:
277+
{{- if .Values.featureGates.useMemoryLimitPercentage }}
278+
- name: GOMEMLIMIT
279+
value: "{{ include "splunk-otel-collector.convertMemToBytes" $agent.resources.limits.memory | int64 }}"
280+
{{- else }}
277281
- name: SPLUNK_MEMORY_TOTAL_MIB
278282
value: "{{ include "splunk-otel-collector.convertMemToMib" $agent.resources.limits.memory | int64 }}"
283+
{{- end }}
279284
- name: K8S_NODE_NAME
280285
valueFrom:
281286
fieldRef:

helm-charts/splunk-otel-collector/templates/deployment-cluster-receiver.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,13 @@ spec:
129129
image: {{ template "splunk-otel-collector.image.otelcol" . }}
130130
imagePullPolicy: {{ .Values.image.otelcol.pullPolicy }}
131131
env:
132+
{{- if .Values.featureGates.useMemoryLimitPercentage }}
133+
- name: GOMEMLIMIT
134+
value: "{{ include "splunk-otel-collector.convertMemToBytes" $clusterReceiver.resources.limits.memory | int64 }}"
135+
{{- else }}
132136
- name: SPLUNK_MEMORY_TOTAL_MIB
133137
value: "{{ include "splunk-otel-collector.convertMemToMib" $clusterReceiver.resources.limits.memory | int64 }}"
138+
{{- end }}
134139
- name: K8S_NODE_NAME
135140
valueFrom:
136141
fieldRef:

helm-charts/splunk-otel-collector/templates/deployment-gateway.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,13 @@ spec:
8484
image: {{ template "splunk-otel-collector.image.otelcol" . }}
8585
imagePullPolicy: {{ .Values.image.otelcol.pullPolicy }}
8686
env:
87+
{{- if .Values.featureGates.useMemoryLimitPercentage }}
88+
- name: GOMEMLIMIT
89+
value: "{{ include "splunk-otel-collector.convertMemToBytes" $gateway.resources.limits.memory | int64 }}"
90+
{{- else }}
8791
- name: SPLUNK_MEMORY_TOTAL_MIB
8892
value: "{{ include "splunk-otel-collector.convertMemToMib" $gateway.resources.limits.memory | int64 }}"
93+
{{- end }}
8994
- name: K8S_NODE_NAME
9095
valueFrom:
9196
fieldRef:

helm-charts/splunk-otel-collector/values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,3 +1406,6 @@ featureGates:
14061406
# The feature gate provides a fix for a scenario where some logs might be missed due to the pod log file being
14071407
# rolled over during high load.
14081408
fixMissedLogsDuringLogRotation: false
1409+
# The feature gate enables the use of the memory_limiter processor based on the percentage.
1410+
# It is required if the helm chart is used with another collector image from upstream.
1411+
useMemoryLimitPercentage: false

0 commit comments

Comments
 (0)