Skip to content

Commit

Permalink
feat: support for configuring memory limit in cluster collector (#1956)
Browse files Browse the repository at this point in the history
Co-authored-by: Ben Elferink <[email protected]>
Co-authored-by: Tamir David <[email protected]>
  • Loading branch information
3 people authored Dec 9, 2024
1 parent 43e210a commit 6ec613c
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 2 deletions.
3 changes: 3 additions & 0 deletions cli/cmd/resources/odigosconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func GetGatewayConfigBasedOnSize(profile common.ProfileName) *common.CollectorGa
RequestCPUm: 150,
LimitCPUm: 300,
RequestMemoryMiB: 300,
LimitMemoryMiB: 300,
}
case sizeMProfile.ProfileName:
return &common.CollectorGatewayConfiguration{
Expand All @@ -82,6 +83,7 @@ func GetGatewayConfigBasedOnSize(profile common.ProfileName) *common.CollectorGa
RequestCPUm: 500,
LimitCPUm: 1000,
RequestMemoryMiB: 500,
LimitMemoryMiB: 600,
}
case sizeLProfile.ProfileName:
return &common.CollectorGatewayConfiguration{
Expand All @@ -90,6 +92,7 @@ func GetGatewayConfigBasedOnSize(profile common.ProfileName) *common.CollectorGa
RequestCPUm: 750,
LimitCPUm: 1250,
RequestMemoryMiB: 750,
LimitMemoryMiB: 850,
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions common/odigos_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ type CollectorGatewayConfiguration struct {
// default value is 500Mi
RequestMemoryMiB int `json:"requestMemoryMiB,omitempty"`

// LimitMemoryMiB is the memory limit for the cluster gateway collector deployment.
// it will be embedded in the deployment as a resource limit of the form "memory: <value>Mi"
// default value is 1.25 the memory request.
LimitMemoryMiB int `json:"limitMemoryMiB,omitempty"`

// RequestCPUm is the CPU request for the cluster gateway collector deployment.
// it will be embedded in the deployment as a resource request of the form "cpu: <value>m"
// default value is 500m
Expand Down
4 changes: 4 additions & 0 deletions docs/pipeline/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ collectorGateway:
# This value will be embedded in the deployment as a resource request of the form "memory: <value>Mi".
requestMemoryMiB: 500

# LimitMemoryMiB is the memory limit for the cluster gateway collector deployment.
# This value will be embedded in the deployment as a resource limit of the form "memory: <value>Mi".
limitMemoryMiB: 625

# RequestCPUm is the CPU request for the cluster gateway collector deployment.
# This value will be embedded in the deployment as a resource request of the form "cpu: <value>m".
requestCPUm: 500
Expand Down
3 changes: 3 additions & 0 deletions helm/odigos/templates/odigos-config-cm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ data:
{{- with .Values.collectorGateway.requestMemoryMiB }}
requestMemoryMiB: {{ . }}
{{- end }}
{{- with .Values.collectorGateway.limitMemoryMiB }}
limitMemoryMiB: {{ . }}
{{- end }}
{{- with .Values.collectorGateway.requestCPUm }}
requestCPUm: {{ . }}
{{- end }}
Expand Down
5 changes: 5 additions & 0 deletions helm/odigos/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ collectorGateway:
# of the form "memory: <value>Mi".
# default value is 500Mi
requestMemoryMiB: 500
# the memory limit for the cluster gateway collector deployment.
# it will be embedded in the deployment as a resource limit
# of the form "memory: <value>Mi".
# default value is 625Mi
limitMemoryMiB: 625

# the CPU request for the cluster gateway collector deployment.
# it will be embedded in the deployment as a resource request
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ func getGatewayResourceSettings(odigosConfig *common.OdigosConfiguration) *odigo
if gatewayConfig != nil && gatewayConfig.RequestMemoryMiB > 0 {
memoryRequestMiB = gatewayConfig.RequestMemoryMiB
}
memoryLimitMiB := int(float64(memoryRequestMiB) * memoryLimitAboveRequestFactor)
if odigosConfig.CollectorGateway != nil && odigosConfig.CollectorGateway.LimitMemoryMiB > 0 {
memoryLimitMiB = odigosConfig.CollectorGateway.LimitMemoryMiB
}
cpuRequestm := defaultRequestCPUm
if gatewayConfig != nil && gatewayConfig.RequestCPUm > 0 {
cpuRequestm = gatewayConfig.RequestCPUm
Expand All @@ -75,8 +79,6 @@ func getGatewayResourceSettings(odigosConfig *common.OdigosConfiguration) *odigo
memoryLimiterSpikeLimitMiB = odigosConfig.CollectorGateway.MemoryLimiterSpikeLimitMiB
}

memoryLimitMiB := int(float64(memoryRequestMiB) * memoryLimitAboveRequestFactor)

gomemlimitMiB := int(memoryLimiterLimitMiB * defaultGoMemLimitPercentage / 100.0)
if odigosConfig.CollectorGateway != nil && odigosConfig.CollectorGateway.GoMemLimitMib != 0 {
gomemlimitMiB = odigosConfig.CollectorGateway.GoMemLimitMib
Expand Down

0 comments on commit 6ec613c

Please sign in to comment.