feat: The ControllerRevision not store the replicas for RBG Roles#61
Merged
cheyang merged 1 commit intosgl-project:mainfrom Oct 23, 2025
Merged
feat: The ControllerRevision not store the replicas for RBG Roles#61cheyang merged 1 commit intosgl-project:mainfrom
cheyang merged 1 commit intosgl-project:mainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
There was a problem hiding this comment.
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.
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
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
make fmt.