feature(rbg): support to use InstanceSet as role workload#110
feature(rbg): support to use InstanceSet as role workload#110cheyang merged 3 commits intosgl-project:mainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
/gemini review |
There was a problem hiding this comment.
Pull request overview
This work-in-progress PR adds support for using InstanceSet as a role workload type in the RoleBasedGroup (RBG) system. The change enables users to define roles with InstanceSet workloads, extending beyond the existing support for StatefulSet, Deployment, and LeaderWorkerSet.
Key changes:
- Introduces InstanceSet workload type support with a new InstanceSetReconciler
- Refactors headless service reconciliation into a shared ServiceReconciler
- Adds support for Components field in RoleSpec for multi-component instance definitions
- Implements LeaderWorkerSet-style topology support for InstanceSet workloads
Reviewed changes
Copilot reviewed 26 out of 30 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
pkg/reconciler/instanceset_reconciler.go |
New reconciler implementing InstanceSet workload lifecycle management |
pkg/reconciler/instanceset_reconciler_test.go |
Comprehensive test suite for InstanceSetReconciler functionality |
pkg/reconciler/svc_reconciler.go |
Extracted and generalized headless service reconciliation logic |
pkg/reconciler/svc_reconciler_test.go |
Tests for the new ServiceReconciler |
pkg/reconciler/workload_reconciler.go |
Added InstanceSet case to workload factory and equality checking |
pkg/reconciler/sts_reconciler.go |
Refactored to use shared ServiceReconciler |
pkg/reconciler/lws_reconciler.go |
Updated injector naming from "env" to "common_env" |
pkg/reconciler/pod_reconciler.go |
Added support for "lws_env" injector alongside "common_env" |
pkg/discovery/injector.go |
New InjectLeaderWorkerSetEnv method for LWS-specific environment variables |
pkg/discovery/env_builder.go |
Added InstanceSet-specific environment variables (INSTANCE_NAME, COMPONENT_NAME, etc.) |
pkg/reconciler/instance/core/instance_core.go |
Added LWS worker index label initialization for InstanceSet pods |
pkg/reconciler/instanceset/sync/update.go |
Fixed type reference from deprecated to unified UpdateStrategyType |
pkg/reconciler/instanceset/core/implement.go |
Fixed type reference from deprecated to unified UpdateStrategyType |
api/workloads/v1alpha1/constant.go |
Added InstanceSetWorkloadType, UpdateStrategyType, and LWS-related constants |
api/workloads/v1alpha1/rolebasedgroup_types.go |
Added Components type and fields to RollingUpdate for InstanceSet support |
api/workloads/v1alpha1/instanceset_types.go |
Unified InstanceSetUpdateStrategyType with UpdateStrategyType |
api/workloads/v1alpha1/zz_generated.deepcopy.go |
Generated deepcopy methods for new Components type |
pkg/utils/constant.go |
Added InstanceSetCrdName constant |
pkg/utils/crds.go |
Added GetInstanceSetGVK helper function |
internal/controller/workloads/rolebasedgroup_controller.go |
Added InstanceSet to owned resources and dynamic CRD watching |
test/wrappers/role_wrapper.go |
Added InstanceSet case to workload type builder |
client-go/applyconfiguration/workloads/v1alpha1/* |
Generated apply configuration types for Components and updated RollingUpdate |
💡 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 adds support for InstanceSet as a workload type for RoleBasedGroup. The changes are extensive, including new API types, a new InstanceSetReconciler, and refactoring of service reconciliation logic. The implementation looks mostly correct, but I've found a few issues.
Specifically:
- The
WorkloadEqualfunction has a bug forInstanceSetthat will cause reconciliation loops. - There are some minor style issues in comments and string formatting.
Additionally, it seems the removal of semanticallyEqualStatefulSet from sts_reconciler.go will cause a compilation error in workload_reconciler.go as it's still being called. Please ensure this is resolved.
I've added specific comments for the issues I found in the changed files.
fa5b020 to
e741df0
Compare
a2317f5 to
c2aaf59
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces support for InstanceSet as a workload for Roles, which is a significant and valuable feature. The changes include new API fields, a new InstanceSetReconciler, and refactoring of the service reconciliation logic. The implementation looks solid, and the inclusion of examples and tests is appreciated. My review focuses on improving API consistency, code clarity, and fixing a potential bug in label assignments to ensure consistency across different workload patterns.
44b884b to
d015a4c
Compare
d015a4c to
3b687be
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 41 out of 41 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
3b687be to
d8aa03b
Compare
d8aa03b to
5685846
Compare
Ⅰ. Motivation
This PR primarily introduces InstanceSet as a configurable workload option for Roles. For details on InstanceSet, see #50 :
Ⅱ. Modifications
Ⅲ. Does this pull request fix one issue?
Ⅳ. List the added test cases (unit test/integration test) if any, please explain if no tests are needed.
Ⅴ. Describe how to verify it
The following pods will be create by such yaml:
A stateful mode of InstanceSet will be supported in v0.6.0, With stateful mode, pods created by instanceSet:
The following pods will be create by such yaml:
The following environment variables are still available in any Pod:
# kubectl exec demo-engine-485s9-worker-1 -- env | grep LWS LWS_WORKER_INDEX=2 LWS_GROUP_SIZE=3 LWS_LEADER_ADDRESS=demo-engine-485s9-leader-0.s-demo-engine.defaultThe following pods will be create by such yaml:
VI. Special notes for reviews
Checklist
make fmt.