Skip to content

Commit

Permalink
Set GOMAXPROCS according to the cpu limit in data-collection (#2347)
Browse files Browse the repository at this point in the history
Similar to #1989 but for the data collection.

---------

Co-authored-by: Amir Blum <[email protected]>
  • Loading branch information
RonFed and blumamir authored Jan 30, 2025
1 parent ca13f98 commit 6e75b40
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
13 changes: 13 additions & 0 deletions autoscaler/controllers/datacollection/daemonset.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,19 @@ func getDesiredDaemonSet(datacollection *odigosv1.CollectorsGroup,
Name: "GOMEMLIMIT",
Value: fmt.Sprintf("%dMiB", datacollection.Spec.ResourcesSettings.GomemlimitMiB),
},
{
// let the Go runtime know how many CPUs are available,
// without this, Go will assume all the cores are available.
Name: "GOMAXPROCS",
ValueFrom: &corev1.EnvVarSource{
ResourceFieldRef: &corev1.ResourceFieldSelector{
ContainerName: containerName,
// limitCPU, Kubernetes automatically rounds up the value to an integer
// (700m -> 1, 1200m -> 2)
Resource: "limits.cpu",
},
},
},
},
LivenessProbe: &corev1.Probe{
ProbeHandler: corev1.ProbeHandler{
Expand Down
6 changes: 6 additions & 0 deletions tests/common/assert/pipeline-ready.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@ spec:
fieldPath: metadata.name
- name: GOMEMLIMIT
(value != null): true
- name: GOMAXPROCS
valueFrom:
resourceFieldRef:
containerName: data-collection
divisor: "0"
resource: limits.cpu
resources:
requests:
(memory != null): true
Expand Down

0 comments on commit 6e75b40

Please sign in to comment.