feat(rbg): support stateful instanceSet#159
Conversation
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
There was a problem hiding this comment.
Pull request overview
Adds support for running InstanceSet in both stateless (unordered) and stateful (ordered) modes, and dispatches reconciliation based on the instance pattern label. This also introduces shared controller utilities (expectations, requeue duration store, rate limiter, history/client helpers) and extends the InstanceSet API/CRD to include a selector and additional status fields.
Changes:
- Add stateful InstanceSet controller implementation and route requests to stateless vs stateful reconcilers.
- Introduce new
pkg/utils/*helpers (expectations, requeue duration store, rate limiter, history wrapper, cache/client helpers, optimized selector conversion). - Update InstanceSet API/CRDs/applyconfigs to include
spec.selectorandstatus.currentReplicas, and rename instance pattern constants.
Reviewed changes
Copilot reviewed 50 out of 529 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/utils/selector.go | Adds a faster label selector conversion path used by controllers. |
| pkg/utils/requeueduration/duration.go | Adds a concurrent-safe shortest-duration store for requeue scheduling. |
| pkg/utils/requeueduration/duration_test.go | Adds unit tests for requeue duration utilities and concurrency behavior. |
| pkg/utils/ratelimiter/rate_limiter.go | Adds a default controller rate limiter with configurable flags. |
| pkg/utils/history/controller_history.go | Introduces a controller-runtime based implementation of k8s controller history interface. |
| pkg/utils/expectations/update_expectations.go | Adds expectations tracking for update flows keyed by controller + revision. |
| pkg/utils/expectations/update_expectations_test.go | Adds unit tests for update expectations behavior. |
| pkg/utils/expectations/scale_expectations.go | Adds expectations tracking for scale create/delete flows. |
| pkg/utils/expectations/scale_expectations_test.go | Adds unit tests for scale expectations. |
| pkg/utils/expectations/resource_version_expectation.go | Adds resourceVersion-based expectation tracking. |
| pkg/utils/expectations/resource_version_expectation_test.go | Adds unit tests for resourceVersion expectations. |
| pkg/utils/expectations/config.go | Adds a default expectations timeout config value. |
| pkg/utils/client/no_deepcopy_lister.go | Adds a cache lister that avoids DeepCopy for performance when explicitly requested. |
| pkg/utils/client/client.go | Adds helper to create a delegating client with a custom User-Agent. |
| pkg/utils/client/cache.go | Wraps controller-runtime cache to optionally support no-deepcopy listing via list option. |
| pkg/reconciler/utils/revisionadapter/revision_adapter.go | Adds a revision label adapter abstraction with a default implementation. |
| pkg/reconciler/pod_reconciler.go | Switches pod defaulting call to client-go’s scheme. |
| pkg/reconciler/instanceset_reconciler.go | Removes deployment-only validation and sets InstanceSet.spec.selector in apply config. |
| pkg/reconciler/instanceset_reconciler_test.go | Updates tests to use new instance pattern constants. |
| pkg/reconciler/instanceset/statelessmode/utils/utils.go | Rewires imports to use in-repo expectations & requeue duration utils. |
| pkg/reconciler/instanceset/statelessmode/sync/update.go | Updates statelessmode sync imports/paths. |
| pkg/reconciler/instanceset/statelessmode/sync/scale.go | Updates statelessmode sync imports/paths and expectations package. |
| pkg/reconciler/instanceset/statelessmode/sync/helper.go | Updates statelessmode helper imports/paths. |
| pkg/reconciler/instanceset/statelessmode/sync/api.go | Updates statelessmode API imports/paths. |
| pkg/reconciler/instanceset/statelessmode/status.go | Renames package to statelessmode and updates imports. |
| pkg/reconciler/instanceset/statelessmode/revision/revision.go | Updates statelessmode revision imports/paths. |
| pkg/reconciler/instanceset/statelessmode/reconciler.go | Moves stateless reconciler under statelessmode and updates deps. |
| pkg/reconciler/instanceset/statelessmode/event_handler.go | Moves stateless event handler under statelessmode and updates deps. |
| pkg/reconciler/instanceset/statelessmode/core/implement.go | Updates stateless core imports/paths. |
| pkg/reconciler/instanceset/statefulmode/stateful_instance_set_utils.go | Adds stateful instance naming/ordinal helpers and availability checks. |
| pkg/reconciler/instanceset/statefulmode/stateful_instance_set_status_updater.go | Adds status updater with retry-on-conflict semantics for stateful controller. |
| pkg/reconciler/instanceset/statefulmode/stateful_instance_set_helper.go | Adds revision patching/apply logic and status calculation helpers. |
| pkg/reconciler/instanceset/statefulmode/stateful_instance_set_controller.go | Adds controller wiring, watches, reconcile loop, and adoption logic for stateful mode. |
| pkg/reconciler/instanceset/statefulmode/stateful_instance_set_control.go | Adds the core control logic for stateful instance lifecycle/update flow. |
| pkg/reconciler/instanceset/statefulmode/stateful_instance_control.go | Adds instance CRUD control surface and event recording for stateful mode. |
| pkg/reconciler/instanceset/statefulmode/instance_ref_manager.go | Adds controllerRef claiming/adopt/release logic for Instances. |
| pkg/reconciler/instance/utils/instance_utils.go | Adjusts component pod naming behavior (pattern check removed). |
| internal/controller/workloads/instanceset_controller.go | Dispatches reconciles to stateless/stateful based on pattern label; updates watches and RBAC markers. |
| go.mod | Adds/adjusts dependencies needed by new controllers/utils. |
| examples/instanceset/instanceset-with-template.yaml | Updates examples to note default Stateful pattern and optional Stateless override. |
| examples/instanceset/instanceset-with-lws.yaml | Updates examples to note default Stateful pattern and optional Stateless override. |
| examples/instanceset/instanceset-with-components.yaml | Updates examples to note default Stateful pattern and optional Stateless override. |
| deploy/helm/rbgs/crds/workloads.x-k8s.io_instancesets.yaml | Updates CRD schema with spec.selector and status.currentReplicas. |
| config/crd/bases/workloads.x-k8s.io_instancesets.yaml | Updates CRD base schema with spec.selector and status.currentReplicas. |
| client-go/applyconfiguration/workloads/v1alpha1/instancesetstatus.go | Adds applyconfiguration field + builder for status.currentReplicas. |
| client-go/applyconfiguration/workloads/v1alpha1/instancesetspec.go | Adds applyconfiguration field + builder for spec.selector. |
| api/workloads/v1alpha1/zz_generated.deepcopy.go | Adds deep-copy support for InstanceSetSpec.Selector. |
| api/workloads/v1alpha1/instanceset_types.go | Adds spec.selector and status.currentReplicas to the API types. |
| api/workloads/v1alpha1/helper.go | Adds RoleBasedGroup.GetKey() helper. |
| api/workloads/v1alpha1/constant.go | Renames instance pattern constants to Stateful/Stateless. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
/gemini review |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 50 out of 529 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Code Review
This pull request introduces support for stateful InstanceSets, which is a significant and well-executed feature. The implementation follows established Kubernetes controller patterns, such as using ControllerRevision for history and adopting logic similar to StatefulSet. The codebase is refactored to cleanly separate stateless and stateful reconciliation logic. My review focuses on improving context propagation and fixing minor issues in documentation and function signatures. Overall, this is a solid contribution.
aaf03dd to
fa0d262
Compare
fa0d262 to
5789a64
Compare
Ⅰ. Motivation
Ⅱ. Modifications
Ⅲ. Does this pull request fix one issue?
fixes #XXXX
Ⅳ. List the added test cases (unit test/integration test) if any, please explain if no tests are needed.
Ⅴ. Describe how to verify it
VI. Special notes for reviews
Checklist
make fmt.