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

[Refactor] Extract KubectlApplyYaml and yaml deserialization to support package #2498

Conversation

MortalHappiness
Copy link
Member

@MortalHappiness MortalHappiness commented Nov 5, 2024

Why are these changes needed?

See the description in the corresponding issue for details.

Related issue number

Closes: #2497

Checks

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

@@ -85,7 +87,6 @@ func TestRayCluster(t *testing.T) {
}
}
g.Eventually(WorkerPods(test, rayCluster), TestTimeoutShort).Should(HaveLen(int(desiredWorkerReplicas)))
g.Expect(rayCluster.Status.DesiredWorkerReplicas).To(Equal(desiredWorkerReplicas))
Copy link
Member

Choose a reason for hiding this comment

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

why remove this?

g.Eventually(WorkerPods(test, rayCluster), TestTimeoutShort).Should(HaveLen(int(desiredWorkerReplicas)))
g.Expect(rayCluster.Status.DesiredWorkerReplicas).To(Equal(desiredWorkerReplicas))
Copy link
Member

Choose a reason for hiding this comment

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

why remove this?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we don't need to check this because we've already checked the number of worker pods above. Also because this is a one-line fix so I do it directly in this refactoring PR. Do you think it's better to create a separate PR?

Copy link
Member

Choose a reason for hiding this comment

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

If I understand correctly, this differs from the above logic. The above logic checks the number of worker Pods by querying the K8s API server, which is the source of truth. The deleted line checks whether the RayCluster status reflects the actual cluster status.

Copy link
Member Author

@MortalHappiness MortalHappiness Nov 5, 2024

Choose a reason for hiding this comment

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

Okay I've restored this check, but updating it to

g.Expect(GetRayCluster(test, namespace.Name, rayCluster.Name)).To(WithTransform(RayClusterDesiredWorkerReplicas, Equal(desiredWorkerReplicas)))

because I found that we forgot to get the RayCluster again to update its status.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Using a transform just to return a field seems overkill :P

Copy link
Member Author

Choose a reason for hiding this comment

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

I used WithTransform because I found there already been a RayClusterDesiredWorkerReplicas function.

Copy link
Member Author

Choose a reason for hiding this comment

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

And GetRayCluster returns 2 parameters: one is raycluster, and the other is error. WithTransform can successfully take only the first one as input and fail if err is not nil. I think this is an ideal and neat syntax.

@kevin85421 kevin85421 self-assigned this Nov 5, 2024
g.Eventually(WorkerPods(test, rayCluster), TestTimeoutShort).Should(HaveLen(int(desiredWorkerReplicas)))
g.Expect(rayCluster.Status.DesiredWorkerReplicas).To(Equal(desiredWorkerReplicas))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Using a transform just to return a field seems overkill :P

@andrewsykim andrewsykim merged commit b875b85 into ray-project:master Nov 5, 2024
29 checks passed
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.

[Refactor] Refactor KubectlApplyYAML and deserialize yaml functions in sample yaml test
3 participants