Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new statefulset workload primitive to the operator-component-framework, matching the existing primitive patterns (builder/resource, mutation planning, flavors, and lifecycle handlers), plus accompanying editor support, docs, and an end-to-end example.
Changes:
- Introduces
pkg/primitives/statefulset/with builder/resource, mutator, handlers, and flavors (plus tests). - Adds
StatefulSetSpecEditorunderpkg/mutation/editors/(plus tests) to support typed spec mutations. - Adds documentation and a runnable example demonstrating the new primitive.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/primitives/statefulset/resource.go | Implements the StatefulSet resource wrapper and default field applicator behavior. |
| pkg/primitives/statefulset/mutator.go | Adds the statefulset mutator with feature-bounded planning and apply ordering (incl. VCT ops). |
| pkg/primitives/statefulset/handlers.go | Provides default converge/grace/suspend handlers for StatefulSets. |
| pkg/primitives/statefulset/flavors.go | Adds field-application flavors for preserving labels/annotations (object + pod template). |
| pkg/primitives/statefulset/builder.go | Provides fluent builder API wiring defaults, mutations, flavors, and handlers. |
| pkg/primitives/statefulset/mutator_test.go | Tests mutator semantics (ordering, snapshots, presence ops, convenience helpers). |
| pkg/primitives/statefulset/handlers_test.go | Tests default handler behavior for converge/grace/suspension. |
| pkg/primitives/statefulset/flavors_test.go | Tests flavor ordering and preservation semantics. |
| pkg/primitives/statefulset/builder_test.go | Tests builder validation and option wiring. |
| pkg/mutation/editors/statefulsetspec.go | Introduces a typed editor for appsv1.StatefulSetSpec. |
| pkg/mutation/editors/statefulsetspec_test.go | Verifies StatefulSetSpecEditor setters and Raw() behavior. |
| examples/statefulset-primitive/main.go | Runnable example using a fake client to reconcile across spec changes and suspension. |
| examples/statefulset-primitive/resources/statefulset.go | Builds a StatefulSet resource with mutations, flavors, custom handlers, and data extraction. |
| examples/statefulset-primitive/features/mutations.go | Example feature mutations demonstrating container edits/presence and metadata edits. |
| examples/statefulset-primitive/features/flavors.go | Example custom flavors and custom converge/grace/suspend behaviors. |
| examples/statefulset-primitive/app/owner.go | Re-exports shared example CRD types for the example package. |
| examples/statefulset-primitive/app/controller.go | Example controller wiring the component framework to the statefulset primitive. |
| examples/statefulset-primitive/README.md | Documentation on running and understanding the example. |
| docs/primitives/statefulset.md | User-facing docs for the new statefulset primitive API and behavior. |
Claude Review Cycle 1 CompleteAddressed:
Intentionally ignored: <!-- claude-review-cycle --> |
Claude Review Cycle 1 CompleteAddressed:
Intentionally ignored: <!-- claude-review-cycle --> |
|
approve |
Claude Review Cycle 1 CompleteAddressed:
Intentionally ignored: <!-- claude-review-cycle --> |
Claude Review Cycle 1 CompleteAddressed:
Intentionally ignored:
<!-- claude-review-cycle --> |
Claude Review Cycle 1 - Follow-up FixThe Fixed in commit 75657ad — <!-- claude-review-cycle-followup --> |
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds builder, resource, mutator, flavors, and handlers for the StatefulSet workload primitive, following the same patterns as the Deployment primitive. Key differences from Deployment: - DefaultFieldApplicator preserves VolumeClaimTemplates (immutable after creation) - Mutator supports EnsureVolumeClaimTemplate/RemoveVolumeClaimTemplate operations - EditStatefulSetSpec provides typed access to StatefulSet-specific fields - VCT operations run after all container edits in the apply order Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Demonstrates building a StatefulSet with feature mutations, flavors, custom status handlers, suspension logic, and data extraction. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Claude Review Cycle 3 CompleteAddressed:
Intentionally ignored: <!-- claude-review-cycle --> |
- Replace all `res, _ := ...Build()` with `res, err := ...Build()` followed by require.NoError in resource_test.go so test failures from Build() are not silently swallowed. - Update WithCustomFieldApplicator docstring to accurately describe that DefaultFieldApplicator deep-copies the entire object (metadata + spec), not just the spec. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Claude Review Cycle 4 CompleteAddressed:
Intentionally ignored: <!-- claude-review-cycle --> |
Replace nil Mutate function with a no-op to ensure test data represents a valid mutation, preventing issues if Build starts validating mutations. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Claude Review Cycle 5 CompleteAddressed:
Intentionally ignored: <!-- claude-review-cycle --> |
| // Selection: | ||
| // - The selector determines which containers the edit function will be called for. | ||
| // - If either selector or edit function is nil, the registration is ignored. | ||
| // - Selector matching is evaluated against a snapshot taken after the current feature's container presence operations are applied. |
There was a problem hiding this comment.
The EditContainers doc comment mentions selector evaluation against a snapshot, but it omits an important implication: container edits earlier in the same feature/mutation do not affect which selectors match later edits (matching is based on the snapshot, not the live-mutated container). Consider documenting this explicitly (as is done in the deployment mutator) to prevent surprising behavior for API consumers.
| // - Selector matching is evaluated against a snapshot taken after the current feature's container presence operations are applied. | |
| // - Selector matching is evaluated against a snapshot taken after the current feature's container presence operations are applied. | |
| // - All container selectors within the same feature are evaluated against this snapshot; they do not see edits made by earlier EditContainers calls. | |
| // - Earlier container edits can change the contents of selected containers but cannot change which containers are matched by later selectors in the same feature. |
Implements the
statefulsetKubernetes resource primitive following the pattern established by the existingConfigMapandDeploymentprimitives.Summary
statefulsetprimitive package underpkg/primitives/statefulset/docs/primitives.md) to list the new primitiveChecklist