mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-21 20:23:39 +09:00
fix(cozy-lib): state the real lower bound in the goMemLimit error
The limit that floors to 0MiB is anything under 4/3 Mi, not under 2Mi: 1536Ki still yields 1MiB. The message named the wrong bound and the tests pinned 2Mi and 1Mi, neither of which sits on the edge. Assisted-by: LLM Signed-off-by: Mattia Eleuteri <mattia@hidora.io>
This commit is contained in:
3 files changed
+11
-10
No files matched your search
@@ -217,7 +217,7 @@
|
||||
{{- $limitMiB := div (mul $memoryLimitInt 3) 4194304 }}
|
||||
{{- /* Go accepts 0, and then collects almost without pause. */}}
|
||||
{{- if lt $limitMiB 1 }}
|
||||
{{- fail (printf "ERROR: a memory limit of %s leaves no room for a Go heap; GOMEMLIMIT needs at least 2Mi." .limits.memory) }}
|
||||
{{- fail (printf "ERROR: a memory limit of %s leaves no room for a Go heap; GOMEMLIMIT needs a limit of at least 1398102 bytes (4/3 Mi) to come out at 1MiB." .limits.memory) }}
|
||||
{{- end }}
|
||||
{{- printf `%dMiB` $limitMiB }}
|
||||
{{- end }}
|
||||
|
||||
@@ -39,15 +39,16 @@ tests:
|
||||
path: data.bareBytes
|
||||
value: "768MiB"
|
||||
|
||||
# The smallest limit that still yields a usable value: 75% of 2Mi
|
||||
# floors to 1MiB.
|
||||
# The smallest limit that still yields a usable value: 75% of
|
||||
# 1398102 bytes (4/3 Mi, rounded up) floors to 1MiB.
|
||||
- equal:
|
||||
path: data.twoMiB
|
||||
path: data.smallestUsable
|
||||
value: "1MiB"
|
||||
|
||||
# Integer division floors, so a limit under 2Mi comes out at 0MiB. Go
|
||||
# accepts that and then collects almost without pause, slowing the
|
||||
# component instead of protecting it, so the render stops instead.
|
||||
# Integer division floors, so a limit one byte under 4/3 Mi comes out
|
||||
# at 0MiB. Go accepts that and then collects almost without pause,
|
||||
# slowing the component instead of protecting it, so the render stops
|
||||
# instead.
|
||||
- it: refuses a limit too small to leave a Go heap
|
||||
values:
|
||||
- resources_gomemlimit_values.yaml
|
||||
@@ -55,7 +56,7 @@ tests:
|
||||
sanitizedResources:
|
||||
belowOneMiB:
|
||||
limits:
|
||||
memory: "1Mi"
|
||||
memory: "1398101"
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorPattern: "leaves no room for a Go heap"
|
||||
@@ -11,6 +11,6 @@ sanitizedResources:
|
||||
bareBytes:
|
||||
limits:
|
||||
memory: "1073741824"
|
||||
twoMiB:
|
||||
smallestUsable:
|
||||
limits:
|
||||
memory: "2Mi"
|
||||
memory: "1398102"
|
||||
Reference in new issue
Block a user