feat(cocoonset): stamp generation onto owned pods for lifecycle bridge#4
Merged
Conversation
cocoon-operator now stamps cs.metadata.generation onto every owned pod via cocoonset.cocoonstack.io/generation. vk-cocoon reads this back as lifecycle-observed-generation when a state transition completes, giving clients a counter-based completion signal that is not subject to wallclock skew. - newManagedPod sets the annotation at pod creation - Reconcile.syncCocoonSetGeneration walks owned pods every reconcile, short-circuits when the annotation is already at cs.Generation - Runs near the top of Reconcile so the projection is in place before any spec-driven patch (applySuspend, etc.) fires Bumps cocoon-common to the lifecycle-state contract commit.
PatchCocoonSetGeneration here is unaffected by the upstream rename (operator only uses the helper signature, not the renamed LifecycleStatus.Annotations() method).
Drop the WHAT-restating sentence on syncCocoonSetGeneration and the short-circuit detail (an implementation note about the helper, not this function's contract). Collapse the duplicate call-site comment in Reconcile to a one-line WHY about placement.
There was a problem hiding this comment.
Pull request overview
Adds a “spec generation → pod annotation” bridge for CocoonSet-owned pods so downstream components (vk-cocoon) can publish a counter-based lifecycle-observed-generation for reliable client completion gating.
Changes:
- Stamp
cocoonset.cocoonstack.io/generationonto newly created managed pods. - Add a reconciler step that patches the generation annotation onto all currently owned pods early in
Reconcile. - Bump
cocoon-commonto a pseudo-version that provides the shared constants/helpers used for stamping.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| go.mod | Bumps github.com/cocoonstack/cocoon-common to the commit that supports lifecycle generation stamping. |
| go.sum | Updates module sums consistent with the cocoon-common bump / tidy. |
| cocoonset/reconciler.go | Invokes generation stamping near the top of reconciliation, before spec-driven pod patches. |
| cocoonset/pods.go | Adds generation annotation when constructing new managed pods. |
| cocoonset/pods_test.go | Adds a unit test verifying newManagedPod stamps the generation annotation. |
| cocoonset/lifecycle.go | Introduces syncCocoonSetGeneration to patch generation onto existing owned pods. |
| cocoonset/lifecycle_test.go | Adds unit tests validating stamping across multiple pods and the “already current” path. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
newManagedPod stamps the annotation, then VMSpec.Apply / ToolboxSpec.Apply mutate annotations afterwards. Apply currently merges via ensurePodAnnotations, but that is a contract of cocoon-common — pin the behavior with a regression test on each build* path so a future replace (instead of merge) implementation fails loudly here.
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.
Summary
cocoon-operator stamps `cocoonset.cocoonstack.io/generation = cs.metadata.generation` onto every owned pod. This is the bridge that lets vk-cocoon publish a counter-based `lifecycle-observed-generation` for clients to gate completion polling on (`obs-gen >= G && state == target`).
Why
Without this bridge, vk-cocoon would have no way to know which spec revision its lifecycle transitions correspond to — clients polling `lifecycle-state == 'hibernated'` cannot distinguish a fresh hibernate from a stale terminal state from a previous lifecycle. Per K8s API conventions, the canonical disambiguator is `status.observedGeneration` paired with the state — counter, not clock.
Dependencies
Test plan