-
Notifications
You must be signed in to change notification settings - Fork 4.2k
test: add unit tests for core/utils and improve nil-safety in helpers #8406
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
base: master
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: kincoy The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Hi @kincoy. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
@feiskyer @vadasambar Hi, could you please re-run the failed workflows? They appear to be unrelated to this PR. Thanks🙏! |
@kincoy sorry I don't have permissions to restart the failed workflow. Can you try creating an empty commit like this to trigger the build (another option is to create a small harmless change like adding new line and removing it later):
|
210db02
to
b585c82
Compare
Thanks for your feedback. I found a minor issue in my changes, which has now been fixed. I’ve pushed the update and all tests have passed. Please help review the latest commit to see if it looks good. Thanks again!🙏。 |
b585c82
to
a21eb0e
Compare
/ok-to-test |
// isVirtualNode determines if the node is created by virtual kubelet | ||
func isVirtualNode(node *apiv1.Node) bool { | ||
return node.ObjectMeta.Labels["type"] == "virtual-kubelet" | ||
if node == nil { |
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.
return node != nil && node.ObjectMeta.Labels["type"] == VirtualKubeletNodeLabelValue
is more concise
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.
Thanks for the suggestion! I agree the one-liner is more concise, but I opted for the explicit if node == nil
form to improve readability and maintainability.
It's quite common to use explicit nil checks, especially when dealing with nested struct access, as it allows easier debugging and extension in the future (e.g., adding logs or metrics inside the nil
branch).
Happy to change if we prefer the concise form globally.
Signed-off-by: kincoy <[email protected]>
a21eb0e
to
00a5c3e
Compare
Friendly ping @jackfrancis — this PR has been idle for a while. Would appreciate a review when convenient 🙏 |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
This PR improves unit test coverage for several utility functions in
core/utils
, helping ensure correctness and robustness of logic that supports autoscaling decisions.Specifically:
FilterOutNodesFromNotAutoscaledGroups
GetOldestCreateTimeWithGpu
hasHardInterPodAffinity
isVirtualNode
isVirtualNode
when passed anil
nodecore/utils/utils.go
from 47.4% to 84.6%before:

after:

Which issue(s) this PR fixes:
N/A — test coverage improvement
Special notes for your reviewer:
isVirtualNode
Does this PR introduce a user-facing change?