Skip to content

Refactor ScaleExtender + block scale-to-zero#2

Open
s4ros wants to merge 2 commits into
masterfrom
fix/scale-extender
Open

Refactor ScaleExtender + block scale-to-zero#2
s4ros wants to merge 2 commits into
masterfrom
fix/scale-extender

Conversation

@s4ros

@s4ros s4ros commented May 25, 2026

Copy link
Copy Markdown
Owner

Summary

  • Introduces a unified dao.Scaler interface and implementation to replace direct type assertions in ScaleExtender. Cleaner handling of different resource types.
  • Refuses to open the scale dialog when the current replica count cannot be determined for a single-resource scale, so a user pressing OK without editing no longer silently scales the workload to zero.

Background

The dao.Scaler refactor was originally bundled into the multi-tab feature branch. Reviewer flagged it as unrelated; it has been extracted here for independent review. The feature/tabs PR contains two revert commits that neutralise these changes there.

Behavioural change in makeScaleForm

Before: when both replicasFromScaleSubresource and replicasFromReady failed, the dialog opened with "0" pre-filled and only a slog.Warn was logged. Confirming without editing → workload scaled to zero.

After:

  • "" is used as the "unknown" sentinel instead of "0", so a legitimate scaled-to-zero workload still pre-fills correctly.
  • For a single-resource scale where both read paths fail, the function returns an error; showScaleDialog surfaces it via the flash bar and the dialog never opens.
  • Bulk-scale (len(fqns) > 1) keeps the documented 0 default — there is no single "current" value to pre-fill there, so the user must explicitly type the target.

Test plan

  • go build ./...
  • Manual smoke: scale a deployment with working RBAC — dialog opens with current count
  • Manual smoke: scale with broken metadata read (e.g., resource removed mid-flight) — flash error, no dialog, no scale
  • Manual smoke: scale a paused (replicas=0) deployment — dialog pre-fills 0 correctly
  • Manual smoke: multi-select scale 2+ deployments — dialog opens with 0 default, user must type target

🤖 Generated with Claude Code

s4ros and others added 2 commits May 25, 2026 00:15
Introduces a unified `dao.Scaler` interface and implementation to handle
resource scaling logic, replacing direct type assertions. This
simplifies the code and makes it more robust when dealing with different
resource types.
When scaling a single resource, the dialog used to pre-fill the replicas
field with "0" whenever both the CRD scale subresource and the READY
column failed to yield a count. A user pressing OK without editing would
silently scale the workload to zero.

makeScaleForm now uses the empty string as an "unknown" sentinel (so a
legitimately scaled-to-zero workload still pre-fills 0) and returns an
error when neither read path succeeds, which the caller surfaces via the
flash bar. Bulk-scale keeps the documented "0 default, must type a
target" behaviour.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
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.

1 participant