R-575: the overcommit warning follows the reader's language

memoryVerdict returns the warning's bundle KEY (KeyMemoryOvercommitWarning)
and DeployStack hands it on; the API renders it per request
(deployWarningData). msgHU, whose only use this was, is gone.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
This commit is contained in:
2026-10-05 22:42:21 +02:00
parent b36a85ac04
commit b05be0ac11
5 changed files with 81 additions and 26 deletions
+8 -4
View File
@@ -248,6 +248,9 @@ const (
// 6. Save app.yaml
// 7. Run docker compose up -d with env vars
// 8. Update in-memory stack state
//
// The string it returns is a bundle KEY for a soft warning ("" = none), never a sentence (R-575): the
// API renders it in the request's language.
func (m *Manager) DeployStack(req DeployRequest) (string, error) {
// Atomically check and set the Deploying flag to prevent concurrent deploys (H1 fix).
m.mu.Lock()
@@ -1472,14 +1475,15 @@ func randomAlphanumeric(length int) (string, error) {
// update replaces the app's own current request, so counting both would refuse an update that fits.
// A deploy releases nothing and passes 0, 0.
//
// Returns the refusal (nil = admitted) and the soft overcommit warning.
// Returns the refusal (nil = admitted) and the soft overcommit warning as a bundle KEY (R-575): no
// language is known here, so the caller that answers a request renders it in that request's language.
//
// v0.253.0 (R-557): the refusal is an ERROR rather than a sentence, and it carries BOTH its kind
// (ErrNotEnoughMemory, so api.deployStatusFor still answers 409) and its message key (so the
// household reads it in its own language). One value where there used to be a sentence plus a
// wrapper at each call site. An unreadable memory reading admits with a WARN, exactly as the deploy
// always has.
func (m *Manager) memoryVerdict(newReqMB, newLimitMB, releasedReqMB, releasedLimitMB int) (refusal error, warning string) {
func (m *Manager) memoryVerdict(newReqMB, newLimitMB, releasedReqMB, releasedLimitMB int) (refusal error, warningKey string) {
reservedMB := m.cfg.System.ReservedMemoryMB
totalMB, usedMB, memErr := system.GetMemoryMB()
// F1: the controller container cannot read the guest's RAM cap from /proc (no lxcfs) or its own
@@ -1522,9 +1526,9 @@ func (m *Manager) memoryVerdict(newReqMB, newLimitMB, releasedReqMB, releasedLim
_, currentLimitMB := m.CommittedMemory()
currentLimitMB -= releasedLimitMB
if newLimitMB > 0 && currentLimitMB+newLimitMB > totalMB {
warning = msgHU("err.stacks.memory_overcommit_warning")
warningKey = KeyMemoryOvercommitWarning
}
return nil, warning
return nil, warningKey
}
// loginAppliedEveryStart is the register of `type: password` fields whose app APPLIES the env value at