Repository navigation
feat: add GOMEMLIMIT env var to Helm chart derived from memory resource limit - #1061
Conversation
|
This change is part of the following stack: Change managed by git-spice. |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the Helm chart to automatically configure Go applications for optimal memory usage within Kubernetes. By dynamically setting the GOMEMLIMIT environment variable based on the container's memory limit, it helps the Go runtime's garbage collector operate more efficiently, reducing the likelihood of out-of-memory (OOM) kills and improving application stability. Highlights
Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request adds support for automatically setting the GOMEMLIMIT environment variable based on the container's memory limit, which is a great feature for Go applications on Kubernetes. The implementation in deployment.yaml and statefulset.yaml is correct in principle, and the new tests and documentation are clear.
However, I've found a significant issue where the implementation conflicts with the documentation's guidance on overriding GOMEMLIMIT. If a user sets a memory limit and also tries to provide a custom GOMEMLIMIT via extraEnvVars, the deployment will fail due to a duplicate environment variable. My review comments provide a solution to make the override functionality work as intended. Addressing this will make the feature robust and user-friendly.
ecc606a to
8c4bd38
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
The pull request introduces automatic GOMEMLIMIT environment variable injection for Go applications deployed via Helm charts, specifically for Kubernetes Deployments and StatefulSets. This feature dynamically sets GOMEMLIMIT based on container memory limits to improve Go's garbage collection and prevent Out-Of-Memory (OOM) kills, with new tests verifying its behavior and updated documentation explaining its usage and override options. A review comment highlights that the docs/!!!meta.json file, which saw an appVersion bump and internal link adjustments, appears to be auto-generated and suggests that such changes should originate from the generating source rather than direct manual edits.
…ce limit Set GOMEMLIMIT automatically from resources.limits.memory in both Deployment and StatefulSet modes using the Kubernetes Downward API resourceFieldRef. This keeps the Go runtime soft memory limit in sync with the container's memory limit, causing GC to run more aggressively as memory approaches the limit and preventing OOM kills. The env var is only injected when resources.limits.memory is set, matching the condition under which a memory limit is meaningful. Both deployment and statefulset templates are updated identically. Four Helm unit tests are added to deployment_test.yaml covering: - GOMEMLIMIT present in Deployment when memory limit is set - GOMEMLIMIT absent in Deployment when no memory limit - GOMEMLIMIT present in StatefulSet when memory limit is set - GOMEMLIMIT absent in StatefulSet when no memory limit
729a6a5 to
d441896
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1061 +/- ##
=====================================
Coverage 5.04% 5.04%
=====================================
Files 6 6
Lines 436 436
=====================================
Hits 22 22
Misses 410 410
Partials 4 4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…ce limit (#1061) Set GOMEMLIMIT automatically from resources.limits.memory in both Deployment and StatefulSet modes using the Kubernetes Downward API resourceFieldRef. This keeps the Go runtime soft memory limit in sync with the container's memory limit, causing GC to run more aggressively as memory approaches the limit and preventing OOM kills. The env var is only injected when resources.limits.memory is set, matching the condition under which a memory limit is meaningful. Both deployment and statefulset templates are updated identically. Four Helm unit tests are added to deployment_test.yaml covering: - GOMEMLIMIT present in Deployment when memory limit is set - GOMEMLIMIT absent in Deployment when no memory limit - GOMEMLIMIT present in StatefulSet when memory limit is set - GOMEMLIMIT absent in StatefulSet when no memory limit (cherry picked from commit 6cdc72d)
|
Successfully created backport PR for |
…ce limit [backport #1061] (#1064) Bot-based backport to `release-0.9`, triggered by a label in #1061. Set GOMEMLIMIT automatically from resources.limits.memory in both Deployment and StatefulSet modes using the Kubernetes Downward API resourceFieldRef. This keeps the Go runtime soft memory limit in sync with the container's memory limit, causing GC to run more aggressively as memory approaches the limit and preventing OOM kills. The env var is only injected when resources.limits.memory is set, matching the condition under which a memory limit is meaningful. Both deployment and statefulset templates are updated identically. Four Helm unit tests are added to deployment_test.yaml covering: - GOMEMLIMIT present in Deployment when memory limit is set - GOMEMLIMIT absent in Deployment when no memory limit - GOMEMLIMIT present in StatefulSet when memory limit is set - GOMEMLIMIT absent in StatefulSet when no memory limit
## Summary The `[Unreleased]` section was populated in #1309 but skewed toward the recent CDC-drain, in-flight-staging, and Ent-migration work, omitting several user-facing features and fixes that also landed since v0.9.4. This backfills the missing notable changes, each cross-referenced by PR. **Added** - `ncps fsck` command + Helm fsck CronJob (#975, #996, #998, #999, #1000, #1004, #1006, #1176) - Closure pinning HTTP endpoints `POST`/`DELETE /pin/{hash}.narinfo`, `GET /pins` (#1108) - pprof server via `--pprof-addr` (#1063) - CDC lazy chunking as a feature + `--cache-cdc-lazy-cleanup-schedule` + recovery cron (#1082, #1083, #1089, #1096) - Helm: auto `GOMEMLIMIT` (#1061), configurable temp volume / `volumeClaimTemplate` (#1074, #1077), SQLite `Recreate` strategy (#1012) - Startup storage reporting + deprecated-narinfo warning (#959, #961) - `docker-dev` image (#1097) **Fixed** - `store/tmp` no longer wiped on startup (#1313) - `nix-hash` NAR verification (#1101) - Prometheus counters primed at startup (#1337, #1343) - 404 on un-reassemblable chunked NARs (#1319), purged narinfo no longer 500 (#1318), fail-fast tmp validation (#1086) - Further CDC/cache reliability fixes (#1317, #1346, #1341, #1342, #1331, #1347) **Changed** - CDC config now persisted in the DB config table (#971) Dependency bumps, CI/test-only changes, and the internal Ent-conversion PRs are intentionally excluded; the existing Ent-migration entry already covers that work. ## Test plan - [x] `nix fmt` reports no changes (docs-only edit) - [x] CHANGELOG section structure intact (Added/Fixed/Changed/Removed/Migration/CI)
Set GOMEMLIMIT automatically from resources.limits.memory in both
Deployment and StatefulSet modes using the Kubernetes Downward API
resourceFieldRef. This keeps the Go runtime soft memory limit in sync
with the container's memory limit, causing GC to run more aggressively
as memory approaches the limit and preventing OOM kills.
The env var is only injected when resources.limits.memory is set,
matching the condition under which a memory limit is meaningful. Both
deployment and statefulset templates are updated identically.
Four Helm unit tests are added to deployment_test.yaml covering: