Skip to content

feat(rbg): support stateful instanceSet#159

Merged
cheyang merged 4 commits intosgl-project:mainfrom
Syspretor:feature/support-index-mode-for-instanceset
Feb 17, 2026
Merged

feat(rbg): support stateful instanceSet#159
cheyang merged 4 commits intosgl-project:mainfrom
Syspretor:feature/support-index-mode-for-instanceset

Conversation

@Syspretor
Copy link
Copy Markdown
Collaborator

Ⅰ. 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

  • Format your code make fmt.
  • Add unit tests or integration tests.
  • Update the documentation related to the change.

@Syspretor Syspretor requested a review from cheyang February 12, 2026 03:27
@gemini-code-assist
Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@RongGu RongGu requested a review from Copilot February 12, 2026 03:36
Copy link
Copy Markdown
Contributor

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

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.selector and status.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.

Comment thread pkg/utils/history/controller_history.go
Comment thread pkg/utils/requeueduration/duration.go
Comment thread pkg/utils/client/client.go
Comment thread pkg/utils/client/no_deepcopy_lister.go
Comment thread pkg/utils/expectations/update_expectations.go
Comment thread pkg/utils/ratelimiter/rate_limiter.go Outdated
Comment thread deploy/helm/rbgs/crds/workloads.x-k8s.io_instancesets.yaml
Comment thread pkg/utils/selector.go Outdated
Comment thread internal/controller/workloads/instanceset_controller.go Outdated
Comment thread internal/controller/workloads/instanceset_controller.go Outdated
@RongGu RongGu requested a review from Copilot February 17, 2026 03:08
@cheyang
Copy link
Copy Markdown
Collaborator

cheyang commented Feb 17, 2026

/gemini review

Copy link
Copy Markdown
Contributor

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 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.

Comment thread pkg/utils/requeueduration/duration.go Outdated
Comment thread pkg/reconciler/instanceset/statefulmode/stateful_instance_set_control.go Outdated
Comment thread internal/controller/workloads/instanceset_controller.go Outdated
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

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.

Comment thread internal/controller/workloads/instanceset_controller.go
Comment thread pkg/reconciler/instanceset/statefulmode/stateful_instance_set_controller.go Outdated
Comment thread pkg/reconciler/instanceset/statefulmode/stateful_instance_set_status_updater.go Outdated
Comment thread config/crd/bases/workloads.x-k8s.io_instancesets.yaml
Comment thread deploy/helm/rbgs/crds/workloads.x-k8s.io_instancesets.yaml
Comment thread pkg/reconciler/instance/utils/instance_utils.go Outdated
Comment thread pkg/reconciler/instanceset/statefulmode/instance_ref_manager.go
Comment thread pkg/utils/selector.go Outdated
@Syspretor Syspretor force-pushed the feature/support-index-mode-for-instanceset branch 4 times, most recently from aaf03dd to fa0d262 Compare February 17, 2026 15:08
@Syspretor Syspretor force-pushed the feature/support-index-mode-for-instanceset branch from fa0d262 to 5789a64 Compare February 17, 2026 15:35
Copy link
Copy Markdown
Collaborator

@cheyang cheyang left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@cheyang cheyang merged commit 5d69cfe into sgl-project:main Feb 17, 2026
8 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.

3 participants