Skip to content

chore: code review pass (hibernation/cocoonset/docs/lint)#6

Merged
CMGS merged 12 commits into
mainfrom
chore-code-review-202605
May 13, 2026
Merged

chore: code review pass (hibernation/cocoonset/docs/lint)#6
CMGS merged 12 commits into
mainfrom
chore-code-review-202605

Conversation

@CMGS
Copy link
Copy Markdown
Contributor

@CMGS CMGS commented May 13, 2026

Summary

Nine independent, single-responsibility commits from a focused code-review pass:

  • Hibernation correctness: tighten the setPhase / markPending short-circuits so a spec-only Generation bump still surfaces through ObservedGeneration instead of being silently swallowed.
  • CocoonSet defense in depth: reject duplicate toolbox names at the controller level (webhook already does this, but an older CRD / bypass would otherwise let one toolbox stomp another). Warn when delete runs without an Epoch registry so misconfig surfaces in logs.
  • Documentation: clean up stale epoch/ references in the README, point readers at registryclient for EPOCH_CA_CERT, replace the misleading "Phase 1" comment in reconcileDelete, and document the ForkFrom drift contract on vmSpecMatches.
  • Tooling: drop the dead _test\.go exclusion rules from .golangci.yml since run.tests: false already skips them. Verified by toggling tests: true and confirming the rules were no longer doing any work the surrounding config wouldn't.

Commits (one logical change each):

  1. fix(hibernation): surface generation bumps in setPhase short-circuit
  2. fix(hibernation): surface generation bumps in markPending short-circuit
  3. fix(cocoonset): reject duplicate toolbox names in ensureToolboxes
  4. chore(cocoonset): warn when delete runs without epoch registry
  5. docs(cocoonset): clarify pod-delete comment in reconcileDelete
  6. docs(cocoonset): note ForkFrom drift behavior for main agents in vmSpecMatches
  7. docs(readme): correct package name from epoch/ to snapshot/
  8. docs(readme): point EPOCH_CA_CERT readers at registryclient
  9. chore(golangci): drop dead per-test exclusion rules

Test plan

  • make lint clean on GOOS=linux
  • make lint clean on GOOS=darwin
  • go test -race -count=1 ./... clean
  • make fmt-check clean
  • make build succeeds
  • New regression tests cover the hibernation setPhase / markPending patches and the new ensureToolboxes duplicate-name guard

CMGS added 11 commits May 13, 2026 15:37
The Phase/VMName equality short-circuit silently dropped status patches
when only Generation moved, leaving ObservedGeneration stuck behind
Generation and tricking clients that rely on it for completion polling.
Require ObservedGeneration to also equal Generation before skipping the
patch, and cover the path with a regression test.
Same class of bug as setPhase: the phase + message equality guard would
swallow status patches when only Generation moved, hiding spec bumps
behind a stale ObservedGeneration. Tighten the guard and add a
regression test.
The webhook already validates this, but a stale CRD or a bypass would
let one toolbox silently overwrite another's pod. Add a controller-level
guard plus a unit test so the failure surfaces even when the webhook is
absent or out of date.
Production wires Epoch unconditionally, so a nil registry at delete time
means either a misconfigured deployment or a test fixture. Either way we
silently skipped tag GC and left snapshots stranded. Emit a warning so
the misconfig surfaces in operator logs.
The "Phase 1" label implies a "Phase 2" downstream that does not exist.
Replace with a description of what actually happens.
…ecMatches

podSpecMatchesAgent only copies ForkFrom into want for slot > 0, so any
manually-edited fork-from on a main pod is treated as drift and triggers
a recreate. Document this so future readers don't restore inheritance.
The interface package was renamed but the README directory tree, the
architecture diagram, and the related-projects table still referred to
it as epoch/SnapshotRegistry. Align all three with the actual
snapshot.Registry name and fix the diagram box alignment that drifted
along the way.
The cocoon-operator never reads EPOCH_CA_CERT itself; the value is
consumed by epoch/registryclient inside NewFromEnv. Point readers at
the canonical source so the env name stays accurate even if the
registryclient adds siblings (EPOCH_TLS_INSECURE etc.) in the future.
run.tests is false, so test files are never linted and the
_test\.go-scoped exclusions (errcheck, gosec, unparam, goconst, gocyclo)
have no effect. Drop them to make the config self-consistent. Verified
behavior unchanged by running both linux + darwin lint passes.
Adapt to commonlog.Setup now returning an error.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR is a multi-commit code review pass improving correctness in hibernation status updates, adding defensive validation to CocoonSet toolbox handling, refreshing docs, and simplifying lint configuration.

Changes:

  • Fix hibernation status short-circuits so spec-only Generation bumps still update status.observedGeneration.
  • Add controller-side rejection for duplicate toolbox names and log a warning when delete runs without a snapshot registry configured.
  • Update README/docs references and remove dead golangci-lint per-test exclusions.

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
README.md Updates repo layout/architecture wording and clarifies epoch registry env var docs.
main.go Handles commonlog.Setup failure explicitly (stderr + exit).
hibernation/reconciler.go Tightens setPhase / markPending short-circuit conditions to include ObservedGeneration.
hibernation/reconciler_test.go Adds regression tests for the ObservedGeneration patching behavior.
cocoonset/toolboxes.go Adds duplicate toolbox-name guard inside ensureToolboxes.
cocoonset/reconciler_test.go Adds test coverage for duplicate toolbox name rejection.
cocoonset/pods.go Doc/comment updates around ForkFrom drift behavior and vmSpecMatches contract.
cocoonset/delete.go Improves delete-path comments and warns when epoch registry is not configured.
.golangci.yml Removes no-op exclusions for _test.go files given run.tests: false.
go.mod Bumps github.com/cocoonstack/cocoon-common dependency version.
go.sum Updates sums to match the cocoon-common bump.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cocoonset/toolboxes.go
Comment thread README.md Outdated
Address Copilot review #4280787224. Hoists the duplicate-name check
out of the main loop so an invalid spec like [a, b, a] no longer
creates pods for a and b before erroring on the second a.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 11 changed files in this pull request and generated no new comments.

Copilot finished work on behalf of CMGS May 13, 2026 10:56
@CMGS CMGS merged commit 56543f0 into main May 13, 2026
10 checks passed
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