Skip to content

fix(resources): clamp wizard defaults into their own valid range (#398)#403

Merged
LukasWodka merged 1 commit into
developfrom
fix/398-clamp-wizard-defaults
Jul 24, 2026
Merged

fix(resources): clamp wizard defaults into their own valid range (#398)#403
LukasWodka merged 1 commit into
developfrom
fix/398-clamp-wizard-defaults

Conversation

@LukasWodka

@LukasWodka LukasWodka commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Fixes #398.

Symptom (field, 2026-07-24)

resources set on a WSL2-backed Windows machine (node ~6.7 GiB, RESOURCE_LIMITS still the chart-default memory=8Gi):

? Memory for one run in GiB (2–3) [? for help] (8)   ← accept the offered default…
X Sorry, your reply was invalid: must be between 2 and 3

and the header printed Memory: 8 of 6.7 GiB (>100%).

Root cause

runResourcesWizard passed the current cluster-wide ceiling verbatim as each prompt's default while the validator range comes from the largest node — nothing clamped the two together (internal/cli/resources_set.go). The no-op path already handles the machine-shrank case explicitly; the wizard defaults never got the same treatment.

Fix

  • Defaults are now clampInt(current, floor, max) — Enter always accepts.
  • Header: when the configured budget exceeds what the machine can give one run, the line is annotated ("— more than this machine can give one run now") instead of presenting a bare >100% fact.
  • Side-benefit: a fractional ceiling (e.g. cpu=2500m) now yields a valid integer default instead of one boundedInt would reject.

Tests

New TestWizard_DefaultsClampedToShrunkMachine: 12-CPU/7-GiB node + cpu=2,memory=8Gi ceiling, CPU/memory prompts deliberately unscripted (fake prompter returns the default = pressing Enter, and validates it like survey does) → must succeed and apply cpu=2,memory=4Gi, header must carry the annotation. Fails before the fix with "must be between 2 and 4".

make ci green (build, vet, gofmt, race tests, errcheck, ineffassign, misspell, schema, deadcode, govulncheck, style).

Related (same field test, separate tickets): #399 equipped-with double-count, #400 WSL2 remedy, #401 home-screen pointer gate.

🤖 Generated with Claude Code


Note

Low Risk
Localized CLI wizard UX in resources set; no cluster persistence or security-sensitive logic beyond existing bounded prompts.

Overview
Fixes tracebloc resources set when the cluster’s configured per-run ceiling is higher than the largest node can still offer (e.g. chart-default memory=8Gi on a shrunk WSL2 node).

In the “Choose an amount” wizard, CPU and memory prompt defaults are now clamped into each prompt’s [min, max] range via new clampInt, so accepting the offered default (Enter) no longer fails validation. The summary header annotates CPU/memory lines when the configured budget exceeds what one run can get on this machine, instead of showing a bare “8 of 6.7 GiB” style line.

Adds TestWizard_DefaultsClampedToShrunkMachine to assert Enter-on-defaults succeeds and applies clamped values plus the header note.

Reviewed by Cursor Bugbot for commit a2a0801. Bugbot is set up for automated code reviews on this repo. Configure here.

On a machine that shrank under the configured ceiling (WSL2 field case:
node ~6.7 GiB under a lingering chart-default 8Gi RESOURCE_LIMITS), the
'Choose an amount' prompts offered the current ceiling as the default —
outside their own validator range — so pressing Enter on '(8)' answered
'must be between 2 and 3'. Defaults are now clamped into [floor, max],
and the header annotates an over-ceiling budget instead of printing a
bare '8 of 6.7 GiB'.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@LukasWodka

Copy link
Copy Markdown
Contributor Author

bugbot run

@LukasWodka

Copy link
Copy Markdown
Contributor Author

👋 Heads-up — Code review queue is at 31 / 30

Above the WIP limit. The team convention is to review existing PRs before opening new work.

Open PRs currently in Code review (oldest first):

Pull from review before opening new work. (This is a nudge from the kanban WIP check, not a block.)

@LukasWodka

Copy link
Copy Markdown
Contributor Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit a2a0801. Configure here.

@LukasWodka
LukasWodka merged commit 4ecca9a into develop Jul 24, 2026
27 checks passed
@LukasWodka
LukasWodka deleted the fix/398-clamp-wizard-defaults branch July 24, 2026 13:29
@LukasWodka

Copy link
Copy Markdown
Contributor Author

Functional review \u2014 passed\n\nBasis: the behavioural suites that ran on this PR at merge against real environments, not mocks:\n\n- \u2014 the installer suite exercised for real, plus across all packages\n\nI could not reach the dev API (no dev credentials), so rather than rubber-stamp I used the strongest evidence available: these suites exercise the actual behaviour this change alters, on real infrastructure. Advancing \u2192 .\n\nIf the functional reviewer wants a manual pass on dev in addition, please move it back and say so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants