Skip to content
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

[Chore] init map with size #2870

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fscnick
Copy link
Contributor

@fscnick fscnick commented Jan 31, 2025

Why are these changes needed?

It would be better to initialize a map with the size if it could be estimated.

For rayClusterLabels, there are two additional assignments besides rayService.Labels.

rayClusterLabel := make(map[string]string)
for k, v := range rayService.Labels {
rayClusterLabel[k] = v
}
rayClusterLabel[utils.RayOriginatedFromCRNameLabelKey] = rayService.Name
rayClusterLabel[utils.RayOriginatedFromCRDLabelKey] = utils.RayOriginatedFromCRDLabelValue(utils.RayServiceCRD)

For rayClusterAnnotations, there are three additional assignments besides rayService.Annotations.

rayClusterAnnotations := make(map[string]string)
for k, v := range rayService.Annotations {
rayClusterAnnotations[k] = v
}
rayClusterAnnotations[utils.HashWithoutReplicasAndWorkersToDeleteKey], err = generateHashWithoutReplicasAndWorkersToDelete(rayService.Spec.RayClusterSpec)
if err != nil {
return nil, err
}
rayClusterAnnotations[utils.NumWorkerGroupsKey] = strconv.Itoa(len(rayService.Spec.RayClusterSpec.WorkerGroupSpecs))
// set the KubeRay version used to create the RayCluster
rayClusterAnnotations[utils.KubeRayVersion] = utils.KUBERAY_VERSION

Related issue number

Checks

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

Copy link
Contributor

@cchung100m cchung100m left a comment

Choose a reason for hiding this comment

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

LGTM, thanks to @fscnick 😄

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.

2 participants