-
Notifications
You must be signed in to change notification settings - Fork 435
Feat: Support role upgrade sequences in stormservice #1432
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat: Support role upgrade sequences in stormservice #1432
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @omerap12, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
I've implemented a new feature to support role upgrade sequences within stormservice
. This enhancement allows for a more controlled and predictable rollout process by enabling users to define a specific order in which different roles should be upgraded. The core change involves adding an UpgradeOrder
field to the RoleSpec
and modifying the sequential rollout logic to respect this order, ensuring that roles are processed in the desired sequence during updates.
Highlights
- New
UpgradeOrder
Field: I've introduced a new optionalUpgradeOrder
field to theRoleSpec
struct. This field allows users to specify a numerical order for how roles should be upgraded, with lower values being upgraded first. If not specified, it defaults to 0. - Controlled Sequential Rollout: The sequential rollout manager (
RollingManagerSequential
) now utilizes this newUpgradeOrder
field. Before performing the rollout, it sorts the roles based on their specified upgrade order, ensuring a controlled and predictable upgrade sequence. - Robust Sorting Logic: I've added a dedicated utility function,
sortRolesByUpgradeOrder
, to handle the sorting logic. This function is robust and correctly manages cases where theUpgradeOrder
is not explicitly set (treatingnil
values as 0). - Comprehensive Unit Tests: Comprehensive unit tests have been added for the
sortRolesByUpgradeOrder
function. These tests cover various scenarios, including empty lists, pre-sorted lists, unsorted lists, and cases withnil
or duplicateUpgradeOrder
values, ensuring the sorting behaves as expected.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
Once approved I will update the docs accordingly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces support for specifying an upgrade order for roles within a RoleSet, allowing for sequential rollouts in a controlled manner. The changes include adding an upgradeOrder
field to the RoleSpec
API, updating the corresponding CRDs, and implementing the sorting logic in the RollingManagerSequential
.
My review has identified a critical issue that could lead to a panic due to unsafe dereferencing of the new upgradeOrder
field during logging. I've also pointed out a medium-severity issue regarding the use of an unstable sort algorithm, which could lead to non-deterministic upgrade sequences for roles with the same priority. I've provided suggestions to address both of these points.
pkg/controller/roleset/rolling.go
Outdated
klog.Infof("[RollingManagerSequential.Next] sorting roleset roles by UpgradeOrder") | ||
sortedRoles := sortRolesByUpgradeOrder(roleSet.Spec.Roles) | ||
klog.Infof("[RollingManagerSequential.Next] Upgrade sequence for roleset %s/%s:", roleSet.Namespace, roleSet.Name) | ||
for i, role := range sortedRoles { | ||
order := int32(0) | ||
if role.UpgradeOrder != nil { | ||
order = *role.UpgradeOrder | ||
} | ||
klog.Infof("[RollingManagerSequential.Next] [%d] Role: %s (UpgradeOrder: %d)", i+1, role.Name, order) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about those logs.. we can remove them / having them in higher verbose level. open to suggestions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like that:
I0810 12:59:12.334938 1 rolling.go:55] [RollingManagerSequential.Next] sorting roleset roles by UpgradeOrder
I0810 12:59:12.334952 1 rolling.go:57] [RollingManagerSequential.Next] Upgrade sequence for roleset default/ordered-update-test-roleset-ls6kd:
I0810 12:59:12.334958 1 rolling.go:59] [RollingManagerSequential.Next] [1] Role: prefill-role (UpgradeOrder: 1)
I0810 12:59:12.335018 1 rolling.go:59] [RollingManagerSequential.Next] [2] Role: decode-role (UpgradeOrder: 2)
I0810 12:59:12.335030 1 rolling.go:64] [RollingManagerSequential.Next] start to rollout roleset default/ordered-update-test-roleset-ls6kd role prefill-role
I0810 12:59:12.335342 1 rolling.go:64] [RollingManagerSequential.Next] start to rollout roleset default/ordered-update-test-roleset-ls6kd role decode-role
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about something like: 🤔
var sequenceLines []string
for i, role := range sortedRoles {
order := int32(0)
if role.UpgradeOrder != nil {
order = *role.UpgradeOrder
}
sequenceLines = append(sequenceLines, fmt.Sprintf("[%d] %s (Order=%d)", i+1, role.Name, order))
}
klog.Infof("[RollingManagerSequential.Next] Upgrade ........", roleSet.Namespace, roleSet.Name, strings.Join(sequenceLines, "\n"))
will take a look 😄 |
/cc @googs1025 please help review the change today. |
// UpgradeOrder specifies the order in which this role should be upgraded. | ||
// Lower values are upgraded first. If not specified, defaults to 0. | ||
// +optional | ||
// +kubebuilder:validation:Minimum=0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use this so that we can remove a lot of == nil
judgments? 🤔
// +kubebuilder:default:=0
Because the comment says default is 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah makes sense. Ill fix that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in 163f384 but I rather keep the == nil
checks ( seemed more "responsible" to me ) if you think it's better to have them off I can adjust.
not sure |
this is very serious scenarios, I think BTW, please hold the change a little bit, let me double check paused upgrade scenarios. If that feature also need api change, we may use |
f72c0c5
to
5a7e176
Compare
let's merge this one, I think this is ok in main branch, Since pause stop will be coming soon. we just need to provide stable api before release. I do not want to block this PR for long time. |
Signed-off-by: Omer Aplatony <[email protected]>
Signed-off-by: Omer Aplatony <[email protected]>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Signed-off-by: Omer Aplatony <[email protected]>
Signed-off-by: Omer Aplatony <[email protected]>
Signed-off-by: Omer Aplatony <[email protected]>
Signed-off-by: Omer Aplatony <[email protected]>
Signed-off-by: Omer Aplatony <[email protected]>
Signed-off-by: Omer Aplatony <[email protected]>
738fd13
to
cc1485c
Compare
Pull Request Description
Support role upgrade sequences in stormservice
Related Issues
Resolves: #1292
Important: Before submitting, please complete the description above and review the checklist below.
Contribution Guidelines (Expand for Details)
We appreciate your contribution to aibrix! To ensure a smooth review process and maintain high code quality, please adhere to the following guidelines:
Pull Request Title Format
Your PR title should start with one of these prefixes to indicate the nature of the change:
[Bug]
: Corrections to existing functionality[CI]
: Changes to build process or CI pipeline[Docs]
: Updates or additions to documentation[API]
: Modifications to aibrix's API or interface[CLI]
: Changes or additions to the Command Line Interface[Misc]
: For changes not covered above (use sparingly)Note: For changes spanning multiple categories, use multiple prefixes in order of importance.
Submission Checklist
By submitting this PR, you confirm that you've read these guidelines and your changes align with the project's contribution standards.