Skip to content

feat: The ControllerRevision not store the replicas for RBG Roles#61

Merged
cheyang merged 1 commit intosgl-project:mainfrom
bcfre:dev-1020
Oct 23, 2025
Merged

feat: The ControllerRevision not store the replicas for RBG Roles#61
cheyang merged 1 commit intosgl-project:mainfrom
bcfre:dev-1020

Conversation

@bcfre
Copy link
Copy Markdown
Collaborator

@bcfre bcfre commented Oct 20, 2025

Ⅰ. Motivation

In an RBG, individual Roles may be associated with an HPA for dynamic scaling.
Storing the Role replica counts in a ControllerRevision can cause some important changes in the spec to be overwritten by outdated replica values (especially since ControllerRevision has a history size limit).

Ⅱ. Modifications

Serialization:
When serializing an RBG into a ControllerRevision, the RBG is first deep-copied. The replicas field for all Roles in the copy is then set to the default value of 1 before running the serialization process.

Deserialization:
The ControllerRevision does not store the actual Role replica counts. After deserialization, the replica counts from the current RBG Roles are used. If a Role from the historical ControllerRevision does not exist in the current RBG, its replica count will default to 1.

Ⅲ. Does this pull request fix one issue?

NONE

Ⅳ. List the added test cases (unit test/integration test) if any, please explain if no tests are needed.

Ⅴ. Describe how to verify it

Ran 28 of 28 Specs in 142.256 seconds
SUCCESS! -- 28 Passed | 0 Failed | 0 Pending | 0 Skipped
--- PASS: TestE2E (142.26s)
PASS
ok sigs.k8s.io/rbgs/test/e2e 142.742s

VI. Special notes for reviews

Checklist

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

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@BSWANG BSWANG requested a review from Copilot October 20, 2025 12:12
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 modifies the ControllerRevision handling for RoleBasedGroup (RBG) to exclude replica counts from being stored in revision history. This prevents outdated replica values from overwriting current replica configurations, which is important when Roles use HPA for dynamic scaling.

Key changes:

  • Modified serialization to set all Role replicas to default value of 1 before storing in ControllerRevision
  • Modified deserialization to restore replica counts from current RBG state instead of historical values
  • Updated test assertions to reflect new behavior where replicas are preserved from current state

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
pkg/utils/revision_utils.go Implements replica exclusion during serialization in getRBGPatch() and replica restoration during deserialization in ApplyRevision()
pkg/utils/revision_utils_test.go Updates test to verify replicas are preserved from current state (v2) instead of being restored from revision (v1)

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread pkg/utils/revision_utils.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 93b5ea5 into sgl-project:main Oct 23, 2025
3 checks passed
@cheyang cheyang added this to the v0.5.0 milestone Oct 23, 2025
@bcfre bcfre deleted the dev-1020 branch December 3, 2025 02:23
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.

4 participants