Skip to content

Conversation

omerap12
Copy link
Contributor

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

  • PR title includes appropriate prefix(es)
  • Changes are clearly explained in the PR description
  • New and existing tests pass successfully
  • Code adheres to project style and best practices
  • Documentation updated to reflect changes (if applicable)
  • Thorough testing completed, no regressions introduced

By submitting this PR, you confirm that you've read these guidelines and your changes align with the project's contribution standards.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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 optional UpgradeOrder field to the RoleSpec 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 new UpgradeOrder 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 the UpgradeOrder is not explicitly set (treating nil 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 with nil or duplicate UpgradeOrder 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

  1. 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.

@omerap12
Copy link
Contributor Author

Once approved I will update the docs accordingly

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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.

Comment on lines 55 to 66
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)
}
Copy link
Contributor Author

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

Copy link
Contributor Author

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

Copy link
Collaborator

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"))

@googs1025 googs1025 self-assigned this Aug 11, 2025
@googs1025
Copy link
Collaborator

will take a look 😄

@Jeffwan
Copy link
Collaborator

Jeffwan commented Aug 12, 2025

/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
Copy link
Collaborator

@googs1025 googs1025 Aug 12, 2025

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

Copy link
Contributor Author

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

Copy link
Contributor Author

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.

@googs1025
Copy link
Collaborator

not sure UpgradePriority or UpgradeOrder I'am both ok with this two

@Jeffwan
Copy link
Collaborator

Jeffwan commented Aug 12, 2025

  1. If we use UpgradePriority, we can use arbitrary numbers. If UpdateOrder is being used, then it has to start with 1.
  2. If we follow exactly one by one upgrade, then it's UpdateOrder, otherwise, UpgradePriority.

this is very serious scenarios, I think upgradeOrder is ok.

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 upgrade.order instead

@Jeffwan
Copy link
Collaborator

Jeffwan commented Aug 21, 2025

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.

omerap12 and others added 8 commits August 21, 2025 13:05
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]>
@Jeffwan Jeffwan force-pushed the stormservice-role-upgrade branch from 738fd13 to cc1485c Compare August 21, 2025 05:05
@Jeffwan Jeffwan merged commit cc6a45e into vllm-project:main Aug 21, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support role upgrade sequences in stormservice
3 participants