Hygiene: comment budget, shared request helpers, dead client verbs, two fixes - #13
Merged
Conversation
Delete numbered section labels, restated code, step narration, and the rationales repeated at godoc and call site; the spaced // nolint:revive directives were inert prose (lint stays at 0 issues without them).
Bundle the warm-pool staleness inputs behind staleCheck, fold the six e2b decode-or-400 blocks and the three body-less sandboxd verbs into one helper each, and drop the must() forwarders that only called benchutil.
Client.ClaimCheckpoint and Client.Promote have no caller in the family:
$ grep -rn --include='*.go' '\.ClaimCheckpoint(\|\.Promote(\|PromoteSpec\|CheckpointClaimSpec' \
sandbox-operator vk-sandbox instar sandbox | grep -v /vendor/
sandbox-operator/pkg/sandboxd/lifecycle.go:143:func (c *Client) ClaimCheckpoint(...)
sandbox-operator/pkg/sandboxd/lifecycle.go:189:func (c *Client) Promote(...)
instar/taskpack/bake/apply.go:85: digest, err := guest.Promote(ctx, sp.Snapshot)
instar/taskpack/node.go:68: tpl, err := g.sb.Promote(ctx, name)
The two instar hits are its own guest SDK, not this client. Client.Sandboxes
and SandboxSummary stay: vk-sandbox reaches them from provider.go, create.go,
orphan.go and inventory/publisher.go.
ensureClaimIdentityLabels now calls setOrDeleteLabel instead of repeating it,
and getOrCreateSandbox drops the template parameter its only call site passes
as nil.
version.Print panicked on a template error instead of returning it, and template.Must panicked on a parse error; both now surface to the only caller, which prints them and exits non-zero. The collectors were registered from a var-initializer IIFE, an init() in disguise that ran in every binary importing the package whether or not it serves /metrics. Register() is now called once from the operator's main, the only process with a controller-runtime metrics server.
CMGS
force-pushed
the
review/hygiene-2-2026-09-03
branch
from
September 3, 2026 06:13
a9d0ee0 to
1150aaf
Compare
Print parses a package constant into a fixed struct, so a parse or execute error is a programmer error a test of Print catches, not a runtime failure reachable under the deployment contract. Returning it cost the caller an os.Exit branch for an impossible path. version.go is back to its master form; the Print test stays.
The test asserted the collectors were absent before Register, which held
only on the first run of a process against the package-global registry:
$ GOWORK=off go test -count=2 ./internal/metrics/
--- FAIL: TestRegisterIsExplicitAndIdempotentlyRefused (0.00s)
metrics_test.go:126: collectors registered before Register was called, count = 1
Register now takes the Registerer, main passes controller-runtime's, and
the test drives its own, so absent -> present -> duplicate holds under
-count=2 and -shuffle=on.
The names and the if !decodeBody(...) { return } call shape carry every
fact the three godocs stated, and unexported helpers get none.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Four commits over the extensions controllers,
pkg/e2bcompat,pkg/sandboxd, the examples and the tagged harnesses. No file underpkg/scale,controllers/orapi/is touched.review:comment budget — 83 comment lines out, 2 in. Numbered section labels, restated code, the#1107adoption rationale written four times, thetriggeredAdoptionEntryandensureClaimIdentityLabelsdocs repeated at their call sites, the duplicatedSandboxTemplate -> claimsTODO, and 17 numbered step-narration comments in the lifecycle example. The spaced// nolint:revivedirectives were inert prose (golangci-lint only honours//nolint); lint stays at0 issues.on both GOOS without them.review:named signatures and shared helpersstaleCheckbundles the four template-state parametersisSandboxStaletook over 8 lines;buildSandboxCRdropspoolNameHash, which it derives from the pool name the same way the caller does.decodeBody/decodeOptionalBodypair replaces six copies of the decode-or-400 block. The required/optional split is deliberate:createSandboxandsetTimeoutmust keep rejecting an absent body, whichdecodeOptionalaccepted.Client.sendNoBodyreplaces the request/auth/drain/status skeleton inRelease,DeleteCheckpointandsandboxVerb, keeping each call's error text and accepted statuses.pollVisible(examples) andpollDetail(e2e) replace seven hand-rolled deadline loops; the sixmust()forwarders now callbenchutil.Mustdirectly.cut:uncalled client verbs —ClaimCheckpointandPromote(withCheckpointClaimSpec,PromoteSpec,PromoteResult) have no caller in sandbox-operator, vk-sandbox, instar or sandbox; the grep is in the commit body.Client.SandboxesandSandboxSummarywere on the same list but are live: vk-sandbox reaches them fromprovider.go,create.go,orphan.goandinventory/publisher.go, so they stay.fix:—version.Printpanicked on a template error rather than returning it, and the collectors were registered from a var-initializer IIFE, aninit()in disguise that ran in every binary importing the package.Register()is now called once from the operator'smain, the only process serving a controller-runtime metrics endpoint. Both have regression tests.Gates
All with
GOWORK=off: