Skip to content

Conversation

@AndySung320
Copy link

Why are these changes needed?

This PR introduces two enhancements to the kubectl plugin to improve autoscaling support.

  1. kubectl ray get workergroups

    • Now reports min and max replica counts for autoscaling groups, in addition to the existing current and desired fields.
  2. kubectl ray scale cluster

    • Allows users to update min and max replicas, along with the existing desired replica count.

Related issue number

Closes #3832

Checks

  • I've made sure the tests are passing.
  • Testing Strategy
    • Unit tests
    • Manual tests
    • This PR is not tested :(

@AndySung320 AndySung320 force-pushed the feature/3832-kubectl-autoscale-support branch from 591c59e to a7fd7dd Compare October 27, 2025 05:44
@AndySung320 AndySung320 force-pushed the feature/3832-kubectl-autoscale-support branch from a7fd7dd to 18a5c9f Compare October 31, 2025 05:43
@AndySung320
Copy link
Author

@win5923 hi~ please take a look, thanks!

@Future-Outlier Future-Outlier self-assigned this Nov 1, 2025
Copy link
Collaborator

@machichima machichima left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also add e2e test to test the actual behavior?

_, err = k8sClient.RayClient().RayV1().RayClusters(options.namespace).Update(ctx, cluster, metav1.UpdateOptions{})
if err != nil {
return fmt.Errorf("failed to scale worker group %s in Ray cluster %s in namespace %s: %w", options.workerGroup, options.cluster, options.namespace, err)
var currentMinReplicas, currentMaxReplicas int32
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to set currentMaxReplicas default to math.MaxInt32

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea, that makes sense!

if options.minReplicas != nil && *options.minReplicas >= 0 && *options.minReplicas != currentMinReplicas {
cluster.Spec.WorkerGroupSpecs[workerGroupIndex].MinReplicas = options.minReplicas
changes = append(changes, fmt.Sprintf("Updated minReplicas: %d to %d", currentMinReplicas, *options.minReplicas))
hasChanges = true
Copy link
Collaborator

@machichima machichima Nov 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can set hasChanges above in if options.minReplicas != nil && *options.minReplicas >= 0 block here

And for setting value cluster.Spec.WorkerGroupSpecs[workerGroupIndex].MinReplicas, we can make it equal to finalMinReplicas so that we can remove this part to make things cleaner

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing this out!
I’ll refactor the update logic for minReplicas, maxReplicas, and replicas to use the final* variables directly within their respective blocks, so that the hasChanges and changes handling can be done inline.

@AndySung320
Copy link
Author

Can we also add e2e test to test the actual behavior?

Thanks for the suggestion.
I'm willing to add e2e tests for both the get and scale commands.
Would you prefer that I include them in this PR, or open a separate follow-up PR focused on e2e coverage?

@Future-Outlier
Copy link
Member

Can we also add e2e test to test the actual behavior?

Thanks for the suggestion. I'm willing to add e2e tests for both the get and scale commands. Would you prefer that I include them in this PR, or open a separate follow-up PR focused on e2e coverage?

In a PR, thank you!

Signed-off-by: AndySung320 <[email protected]>
- Add getWorkerGroupValues helper function to support.go
- Add e2e tests for 'kubectl ray scale cluster' command
- Add e2e tests for 'kubectl ray get workergroups' command

Signed-off-by: AndySung320 <[email protected]>
Refactor the update logic for minReplicas, maxReplicas, and replicas
to use the final* variables directly within their respective blocks.

Signed-off-by: AndySung320 <[email protected]>
Signed-off-by: AndySung320 <[email protected]>
@AndySung320 AndySung320 force-pushed the feature/3832-kubectl-autoscale-support branch from 9f2aef6 to a3901e8 Compare November 14, 2025 06:57
@AndySung320
Copy link
Author

hi @machichima @Future-Outlier ,
all review comments addressed and CI is passing now. PTAL~

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.

[Feature] [kubectl-plugin] Improve support for autoscaling clusters

4 participants