refactor(rbgs): change spec api field#206
Merged
cheyang merged 4 commits intosgl-project:mainfrom Mar 17, 2026
Merged
Conversation
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
97c1342 to
abb1947
Compare
cheyang
reviewed
Mar 16, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the RoleBasedGroupSet API to replace the spec.template field with a new spec.groupTemplate wrapper type, and updates controller logic/tests and generated client/apply code accordingly.
Changes:
- Introduces
RoleBasedGroupTemplateSpecand updatesRoleBasedGroupSetSpecto useGroupTemplatein both v1alpha1 and v1alpha2 APIs. - Refactors the RoleBasedGroupSet controller and unit tests to read roles from
spec.groupTemplate.spec. - Regenerates/updates client-go apply configurations and deepcopy code to match the new API shape.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| test/wrappers/v1alpha2/rbgs_wrapper.go | Updates test builder to populate Spec.GroupTemplate.Spec instead of Spec.Template. |
| test/wrappers/v1alpha1/rbgs_wrapper.go | Same wrapper update for v1alpha1. |
| internal/controller/workloads/rolebasedgroupset_controller_test.go | Updates controller tests to construct RBGS objects using GroupTemplate. |
| internal/controller/workloads/rolebasedgroupset_controller.go | Switches controller reads/writes from Spec.Template to Spec.GroupTemplate.Spec. |
| client-go/applyconfiguration/workloads/v1alpha2/rolebasedgrouptemplatespec.go | Adds apply-config type for the new template wrapper (v1alpha2). |
| client-go/applyconfiguration/workloads/v1alpha2/rolebasedgroupsetspec.go | Replaces apply-config Template with GroupTemplate (v1alpha2). |
| client-go/applyconfiguration/workloads/v1alpha1/rolebasedgrouptemplatespec.go | Adds apply-config type for the new template wrapper (v1alpha1). |
| client-go/applyconfiguration/workloads/v1alpha1/rolebasedgroupsetspec.go | Replaces apply-config Template with GroupTemplate (v1alpha1). |
| api/workloads/v1alpha2/zz_generated.deepcopy.go | Adds deepcopy for RoleBasedGroupTemplateSpec and updates RBGS spec deepcopy (v1alpha2). |
| api/workloads/v1alpha2/rolebasedgroupset_types.go | Adds RoleBasedGroupTemplateSpec and replaces Template with GroupTemplate (v1alpha2). |
| api/workloads/v1alpha1/zz_generated.deepcopy.go | Adds deepcopy for RoleBasedGroupTemplateSpec and updates RBGS spec deepcopy (v1alpha1). |
| api/workloads/v1alpha1/rolebasedgroupset_types.go | Adds RoleBasedGroupTemplateSpec and replaces Template with GroupTemplate (v1alpha1). |
Comments suppressed due to low confidence (1)
internal/controller/workloads/rolebasedgroupset_controller.go:384
needsUpdateonly compares child roles toGroupTemplate.Spec.Roles. Now that the template type includesmetadata(and potentially other spec fields), updates togroupTemplate.metadataor other template fields won’t trigger reconciliation updates for existing children. Either remove unsupported fields from the template type, or extend update detection/propagation to cover the intended template surface (e.g., template labels/annotations).
// needsUpdate checks if a child RBG needs to be updated based on changes in the parent RBGSet.
func (r *RoleBasedGroupSetReconciler) needsUpdate(
rbgset *workloadsv1alpha2.RoleBasedGroupSet, rbg *workloadsv1alpha2.RoleBasedGroup,
) bool {
// Check if the template spec has changed using order-insensitive comparison
if !r.rolesEqual(rbg.Spec.Roles, rbgset.Spec.GroupTemplate.Spec.Roles) {
return true
}
// Check if annotations need to be propagated
return r.needsAnnotationUpdate(rbgset, rbg)
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
cheyang
reviewed
Mar 16, 2026
cheyang
reviewed
Mar 16, 2026
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.
Ⅰ. 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.