Repository navigation
[feat] Support topologySpreadConstraints on backend, workflows, workers and code executor - #422
Conversation
[Medium impact] The rules affect pod placement across several Retool Deployments in one chart. The PR appears safe to merge, with non-blocking improvements needed for empty overrides and tests. FindingsReviews (1) · Last reviewed commit: "[feat] Support topologySpreadConstraints..." · Reviewed by Greptile |
ee3202a to
829d716
Compare
|
@mertbozfakioglu @tomgoren-retool could one of you take a look at this when you have a moment? I rebased it onto Thanks! |
mertbozfakioglu
left a comment
There was a problem hiding this comment.
Non-blocking suggestion: let the workflow backend take its own workflows.backend.topologySpreadConstraints, the way the workers take workflows.worker.topologySpreadConstraints.
The three suggestions belong together. The two values.yaml copies must stay identical for values-yaml-synced, so please apply them as one batch ("Add suggestion to batch").
| affinity: | ||
| {{ toYaml .Values.affinity | indent 8 }} | ||
| {{- end }} | ||
| {{- $topologySpreadConstraints := include "retool.topologySpreadConstraints" (dict "sources" (list .Values.workflows .Values) "selectorLabels" (include "retool.workflowBackend.selectorLabels" . | fromYaml)) }} |
There was a problem hiding this comment.
| {{- $topologySpreadConstraints := include "retool.topologySpreadConstraints" (dict "sources" (list .Values.workflows .Values) "selectorLabels" (include "retool.workflowBackend.selectorLabels" . | fromYaml)) }} | |
| {{- $topologySpreadConstraints := include "retool.topologySpreadConstraints" (dict "sources" (list .Values.workflows.backend .Values.workflows .Values) "selectorLabels" (include "retool.workflowBackend.selectorLabels" . | fromYaml)) }} |
Small suggestion. This lets the backend read its own list from workflows.backend, the same way the workers use workflows.worker, and falls through to workflows and then the global list when it's unset.
| # Per-component overrides. The most specific block that sets the key wins and | ||
| # replaces this list. Set an override to [] to disable constraints for that | ||
| # component; leave it unset to inherit: | ||
| # workflows.topologySpreadConstraints (workflow backend and workflow workers) |
There was a problem hiding this comment.
| # workflows.topologySpreadConstraints (workflow backend and workflow workers) | |
| # workflows.topologySpreadConstraints (workflow backend and workflow workers) | |
| # workflows.backend.topologySpreadConstraints |
Documents the new override. The root values.yaml needs the same edit.
| # Per-component overrides. The most specific block that sets the key wins and | ||
| # replaces this list. Set an override to [] to disable constraints for that | ||
| # component; leave it unset to inherit: | ||
| # workflows.topologySpreadConstraints (workflow backend and workflow workers) |
There was a problem hiding this comment.
| # workflows.topologySpreadConstraints (workflow backend and workflow workers) | |
| # workflows.topologySpreadConstraints (workflow backend and workflow workers) | |
| # workflows.backend.topologySpreadConstraints |
Same edit as in charts/retool/values.yaml, to keep the two copies in sync.
|
I pushed the changes for the small comments I had left, should still work for you. Thanks for doing this! Will merge soon as I verify this on real infra |
…rs and code executor Add a top-level topologySpreadConstraints value, with per-component overrides that follow the existing affinity fallback order (worker -> parent -> global, or component -> global). A constraint without a labelSelector gets the selector labels of the pod's own component. One list can then spread each Deployment on its own pods, for example across zones, without a separate selector per component. The default is an empty list, so rendered manifests do not change unless the value is set. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolve the list by key presence instead of `default`: the most specific values block that sets topologySpreadConstraints wins, so an explicit [] disables constraints for that component while an unset key still inherits. Add .github/test_topology_spread_constraints.py with render assertions: each component selects only its own pods, an explicit labelSelector is kept, worker and parent overrides apply only where set, an empty override disables constraints, and the default renders none. The option fixture now uses an explicit selector that differs from the injected one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…hema Follows the convention from tryretool#427: top-level keys without schema annotations are marked @Schema hidden, so they stay out of values.schema.json and README.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…flow backend The workflow backend now reads workflows.backend first, then workflows, then the global list, the same way the workers read workflows.worker. Existing values render the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
c4ead07 to
6e62e59
Compare
Summary
The chart exposes
affinity,nodeSelectorandtolerationsbut nottopologySpreadConstraints. Without them, there is no way to spread Retool replicas evenly across availability zones. On clusters with per-zone node pools (for example Karpenter), the scheduler keeps placing new replicas in the first zone that has room. Running pods are never rebalanced, so one zone fills up first.This PR adds
topologySpreadConstraintsto these Deployments:deployment_backend.yaml)deployment_workflows.yaml)_workers.tpl)deployment_code_executor.yaml)Values
topologySpreadConstraints: new top-level list, default[].<parent>.worker/agents.evalWorker, then<parent>, then globalworkflows, then globalcodeExecutor, then globalThe first block that sets the key wins. An explicit
[]therefore disables constraints for that component, and an unset key inherits from the next block. This useshasKeyrather thandefault, becausedefaultwould treat[]as unset.A constraint without a
labelSelectorgets the selector labels of the pod's own component, through theretool.topologySpreadConstraintshelper. One global list then spreads each Deployment over its own pods only:A constraint that sets its own
labelSelectoris rendered unchanged.Testing
New
.github/test_topology_spread_constraints.py, added to thelint-chartjob. It asserts that:spec.selector.matchLabels, and no two components share a selector;labelSelectoris kept as written (the code executor in the fixture);agents.evalWorker) applies to that worker only;agents) applies to both agent workers and not to the workflow worker;[]override disables constraints for that component only.I mutation-tested the assertions. Each of these changes makes at least one test fail:
defaultsemantics instead ofhasKey, the backend selector used for workers, and always overwritinglabelSelector.Also checked:
[],helm templateoutput is identical tomainforci/test-install-values.yamlmerged with each existingci/*-option.yamlfile. Only random generated secrets differ.helm lintpasses. Bothvalues.yamlcopies are in sync. The chart version is bumped to 6.14.3.schema/generate.sh --checkpasses; the new top-level key is marked@schema hiddenlike its neighbours.🤖 Generated with Claude Code