Skip to content

refactor(rbgs): change spec api field#206

Merged
cheyang merged 4 commits intosgl-project:mainfrom
Syspretor:refactor/change-api-fields-of-rbgs
Mar 17, 2026
Merged

refactor(rbgs): change spec api field#206
cheyang merged 4 commits intosgl-project:mainfrom
Syspretor:refactor/change-api-fields-of-rbgs

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.

@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!

@Syspretor Syspretor force-pushed the refactor/change-api-fields-of-rbgs branch from 97c1342 to abb1947 Compare March 16, 2026 12:40
@RongGu RongGu requested a review from Copilot March 16, 2026 12:43
Comment thread internal/controller/workloads/rolebasedgroupset_controller.go
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

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 RoleBasedGroupTemplateSpec and updates RoleBasedGroupSetSpec to use GroupTemplate in 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

  • needsUpdate only compares child roles to GroupTemplate.Spec.Roles. Now that the template type includes metadata (and potentially other spec fields), updates to groupTemplate.metadata or 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.

Comment thread internal/controller/workloads/rolebasedgroupset_controller.go Outdated
Comment thread api/workloads/v1alpha2/rolebasedgroupset_types.go Outdated
Comment thread api/workloads/v1alpha2/rolebasedgroupset_types.go
Comment thread api/workloads/v1alpha1/rolebasedgroupset_types.go Outdated
Comment thread api/workloads/v1alpha1/rolebasedgroupset_types.go Outdated
Comment thread internal/controller/workloads/rolebasedgroupset_controller.go Outdated
Comment thread internal/controller/workloads/rolebasedgroupset_controller.go
Comment thread internal/controller/workloads/rolebasedgroupset_controller_test.go
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 3a4e178 into sgl-project:main Mar 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