Skip to content
Draft
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
2 changes: 1 addition & 1 deletion charts/retool/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: retool
description: A Helm chart for Kubernetes
type: application
version: 6.11.18
version: 6.11.19
maintainers:
- name: Retool Engineering
email: engineering+helm@retool.com
Expand Down
39 changes: 39 additions & 0 deletions charts/retool/ci/test-js-executor-hpa-option.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
rr:

# Exercises the JS executor HPA (opt-in via rr.jsExecutor.autoscaling).
# Overlaid on top of test-install-values.yaml. Covers CPU, memory, extra
# metrics, and scale behavior branches; replicaCount must be omitted from
# the Deployment when the HPA is enabled.
jsExecutor:
enabled: true
replicaCount: 3
image:
repository: tryretool/js-executor-service
tag: 3.123.4
autoscaling:
enabled: true
minReplicas: 2
maxReplicas: 8
targetCPUUtilizationPercentage: 70
targetMemoryUtilizationPercentage: 80
metrics:
- type: Pods
pods:
metric:
name: packets-per-second
target:
type: AverageValue
averageValue: 1k
behavior:
scaleDown:
stabilizationWindowSeconds: 300
policies:
- type: Percent
value: 50
periodSeconds: 60
scaleUp:
stabilizationWindowSeconds: 0
policies:
- type: Percent
value: 100
periodSeconds: 15
67 changes: 67 additions & 0 deletions charts/retool/templates/deployment_js_executor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ metadata:
{{ toYaml .Values.deployment.annotations | indent 4 }}
{{- end }}
spec:
{{- if not ((.Values.rr.jsExecutor.autoscaling).enabled) }}
replicas: {{ .Values.rr.jsExecutor.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "retool.jsExecutor.selectorLabels" . | nindent 6 }}
Expand Down Expand Up @@ -258,4 +260,69 @@ spec:
matchLabels:
{{- include "retool.jsExecutor.selectorLabels" . | nindent 6 }}
{{- end }}
{{- if (.Values.rr.jsExecutor.autoscaling).enabled }}
{{- $hpa := .Values.rr.jsExecutor.autoscaling }}
{{- $requests := ((.Values.rr.jsExecutor.resources).requests | default dict) }}
{{- if and $hpa.targetCPUUtilizationPercentage (not $requests.cpu) }}
{{- fail "rr.jsExecutor.autoscaling.targetCPUUtilizationPercentage requires rr.jsExecutor.resources.requests.cpu. CPU utilization is unavailable without a CPU request, so the HPA cannot scale on CPU. Set a CPU request or unset targetCPUUtilizationPercentage." }}
{{- end }}
{{- if and $hpa.targetMemoryUtilizationPercentage (not $requests.memory) }}
{{- fail "rr.jsExecutor.autoscaling.targetMemoryUtilizationPercentage requires rr.jsExecutor.resources.requests.memory. Memory utilization is unavailable without a memory request, so the HPA cannot scale on memory. Set a memory request or unset targetMemoryUtilizationPercentage." }}
{{- end }}
{{- range $hpa.metrics }}
{{- if eq (toString .type) "Resource" }}
{{- $name := (.resource).name | default "" }}
{{- $targetType := ((.resource).target).type | default "" }}
{{- if and (eq $targetType "Utilization") $name (not (index $requests $name)) }}
{{- fail (printf "rr.jsExecutor.autoscaling.metrics Resource Utilization target %q requires rr.jsExecutor.resources.requests.%s. Utilization is unavailable without that request, so the HPA cannot scale on it. Set the request or use an AverageValue target instead." $name $name) }}
{{- end }}
{{- else if eq (toString .type) "ContainerResource" }}
{{- $name := (.containerResource).name | default "" }}
{{- $targetType := ((.containerResource).target).type | default "" }}
{{- if and (eq $targetType "Utilization") $name (not (index $requests $name)) }}
{{- fail (printf "rr.jsExecutor.autoscaling.metrics ContainerResource Utilization target %q requires rr.jsExecutor.resources.requests.%s. Utilization is unavailable without that request, so the HPA cannot scale on it. Set the request or use an AverageValue target instead." $name $name) }}
{{- end }}
Comment on lines +282 to +284

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Wrong container request validated

When a ContainerResource Utilization metric targets an extra container, this branch checks rr.jsExecutor.resources.requests for the main JS executor instead of the selected container. Helm therefore accepts a metric whose target lacks the request, leaving that HPA metric unavailable, or rejects a valid metric when only the target container has the request.

Knowledge Base Used:

{{- end }}
{{- end }}
---
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ template "retool.jsExecutor.name" . }}
labels:
{{- include "retool.jsExecutor.selectorLabels" . | nindent 4 }}
{{- include "retool.jsExecutor.labels" . | nindent 4 }}
{{- include "retool.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ template "retool.jsExecutor.name" . }}
minReplicas: {{ .Values.rr.jsExecutor.autoscaling.minReplicas }}
maxReplicas: {{ .Values.rr.jsExecutor.autoscaling.maxReplicas }}
metrics:
{{- if .Values.rr.jsExecutor.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ .Values.rr.jsExecutor.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.rr.jsExecutor.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
Comment thread
greptile-apps[bot] marked this conversation as resolved.
averageUtilization: {{ .Values.rr.jsExecutor.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- with .Values.rr.jsExecutor.autoscaling.metrics }}
{{- toYaml . | nindent 4 }}
{{- end }}
Comment thread
greptile-apps[bot] marked this conversation as resolved.
{{- with .Values.rr.jsExecutor.autoscaling.behavior }}
behavior:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
{{- end }}
24 changes: 24 additions & 0 deletions charts/retool/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,28 @@ rr:

replicaCount: 1

# Horizontal Pod Autoscaler for the JS executor. Disabled by default;
# set enabled: true to opt in. When enabled, replicaCount is ignored
# and the HPA controls the replica count.
#
# CPU and memory Utilization targets (the shortcuts below, and any
# Resource / ContainerResource Utilization metric in autoscaling.metrics)
# require a matching container request (resources.requests.<name>). A
# limits-only or partial resources override leaves those metrics
# unavailable and the HPA will not scale on the affected resource.
autoscaling:
enabled: false
minReplicas: 1
maxReplicas: 10
targetCPUUtilizationPercentage: 70
targetMemoryUtilizationPercentage: 70
# Additional HPA metrics (Pods, Object, External, or extra Resource).
# Resource Utilization metrics here have the same request requirement
# as the CPU/memory shortcuts above.
# metrics: []
# Scaling behavior (stabilization windows and policies).
# behavior: {}

seccompLocalhostProfile: profiles/nsjail-seccomp.json

# JS-executor-specific environment; not inherited from the top-level
Expand All @@ -887,6 +909,8 @@ rr:
# Resources for the JS executor. Memory request and limit are kept equal:
# JSE reads its memory limit and rejects requests at 80% of it, so the
# request must reserve the full amount to avoid premature rejections.
# HPA Utilization metrics (see autoscaling above) also require these
# requests; do not drop them if autoscaling is enabled.
resources:
limits:
cpu: '2'
Expand Down
24 changes: 24 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,28 @@ rr:

replicaCount: 1

# Horizontal Pod Autoscaler for the JS executor. Disabled by default;
# set enabled: true to opt in. When enabled, replicaCount is ignored
# and the HPA controls the replica count.
#
# CPU and memory Utilization targets (the shortcuts below, and any
# Resource / ContainerResource Utilization metric in autoscaling.metrics)
# require a matching container request (resources.requests.<name>). A
# limits-only or partial resources override leaves those metrics
# unavailable and the HPA will not scale on the affected resource.
autoscaling:
enabled: false
minReplicas: 1
maxReplicas: 10
targetCPUUtilizationPercentage: 70
targetMemoryUtilizationPercentage: 70
# Additional HPA metrics (Pods, Object, External, or extra Resource).
# Resource Utilization metrics here have the same request requirement
# as the CPU/memory shortcuts above.
# metrics: []
# Scaling behavior (stabilization windows and policies).
# behavior: {}

seccompLocalhostProfile: profiles/nsjail-seccomp.json

# JS-executor-specific environment; not inherited from the top-level
Expand All @@ -887,6 +909,8 @@ rr:
# Resources for the JS executor. Memory request and limit are kept equal:
# JSE reads its memory limit and rejects requests at 80% of it, so the
# request must reserve the full amount to avoid premature rejections.
# HPA Utilization metrics (see autoscaling above) also require these
# requests; do not drop them if autoscaling is enabled.
resources:
limits:
cpu: '2'
Expand Down
Loading