feat(shield): set GOMAXPROCS/GOMEMLIMIT for Go workloads on Windows - #2660
Closed
francesco-furlan wants to merge 1 commit into
Closed
feat(shield): set GOMAXPROCS/GOMEMLIMIT for Go workloads on Windows#2660francesco-furlan wants to merge 1 commit into
francesco-furlan wants to merge 1 commit into
Conversation
Windows containers have no cgroups, so the Go runtime cannot auto-detect the container's CPU/memory limits and falls back to whole-node CPU count with no memory ceiling. Set GOMAXPROCS/GOMEMLIMIT explicitly via the downward API (resourceFieldRef) so they track whatever the chart renders. - New common.go_runtime.envs helper emits each var only when its limit is set - host-shield-windows DaemonSet: always tuned (always Windows) - cluster-shield Deployment: tuned only when pinned to Windows nodes, detected via the effective nodeSelector (kubernetes.io/os: windows) - Emitted before the user-env include so users can still override - Linux host-shield left unchanged (Go auto-detects cgroup limits there)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Sets
GOMAXPROCS/GOMEMLIMITexplicitly for Shield's Go workloads on Windows, derived from each container's own resource limits via the downward API (resourceFieldRef).Why
Modern Go reads cgroup CPU/memory limits automatically on Linux. Windows containers have no cgroups, so the runtime falls back to whole-node CPU count and no memory ceiling — causing scheduler contention and OOM risk under tight limits. We pin the runtime to whatever the chart renders, only where Go can't auto-detect (Windows).
Changes
templates/common/_go_runtime.tpl(new) —common.go_runtime.envshelper. Emits each env var only when its matching limit is set (limits.cpu→GOMAXPROCS,limits.memory→GOMEMLIMITwithdivisor: "1").templates/host/daemonset-windows.yaml— always tuned (always Windows).templates/cluster/deployment.yaml— tuned only when pinned to Windows nodes.templates/cluster/_helpers.tpl— newcluster.scheduled_on_windowsdetector (checks effective nodeSelector forkubernetes.io/os: windows).host-shieldDaemonSet left unchanged (Go auto-detects there).Chart.yamlbumped1.43.2→1.44.0.Notes
Verification
helm template: Windows DaemonSet always tuned; cluster-shield tuned only when Windows-pinned; both gated on limits; Linux host DaemonSet untouched.helm unittest: 37 suites / 560 tests pass.🤖 Generated with Claude Code