Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Summary of ChangesHello, 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! This pull request addresses a bug in the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe 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 by creating a comment using either
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 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. 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
|
There was a problem hiding this comment.
Code Review
This pull request provides a significant and well-implemented refactoring of the UpdateHyperNode logic. The changes correctly handle spec modifications, member updates, and tier changes, introducing a performance-optimizing fast-path for updates that don't require a full cache rebuild. The new logic properly manages hypernodes with regex or label selectors that depend on the live cluster state. A key improvement is the handling of member removal, which now triggers a rebuild for other hypernodes that might adopt the freed members, resolving potential parent-child relationship issues. The accompanying tests are thorough and cover the new scenarios effectively. My review identified one minor issue: a leftover debug print statement in a test file that should be removed.
| } | ||
| assert.Equal(t, false, hni.Ready()) | ||
|
|
||
| fmt.Printf("%v\n", hni.HyperNodesInfo()) |
There was a problem hiding this comment.
Pull request overview
Fixes UpdateHyperNode cache rebuild behavior so scheduler topology state stays consistent when HyperNode specs change, regex/label selectors are involved, or members are released and can be adopted by other HyperNodes.
Changes:
- Add spec-diffing and a fast-path to skip rebuilds when spec is unchanged and members are exact-match only.
- Reintroduce “always rebuild” behavior for regex/label selectors and rebuild caches when members change (including rebuilding claimers of newly-freed members).
- Update and expand
UpdateHyperNodeunit tests to cover no-op updates, tier-only updates, regex rebuilds, and member-change rebuilds.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pkg/scheduler/api/hyper_node_info.go | Refactors UpdateHyperNode rebuild logic, adds regex/label rebuild detection, rebuilds affected claimers, and threads a pre-listed node slice into rebuild functions. |
| pkg/scheduler/api/hyper_node_info_test.go | Adds focused tests for new rebuild semantics and adjusts existing multiple-parent test coverage. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| fmt.Printf("%v\n", hni.HyperNodesInfo()) | ||
|
|
There was a problem hiding this comment.
Avoid printing directly to stdout in tests (fmt.Printf). This adds noisy output to go test runs and forces an extra import. If you need diagnostics, use t.Logf/t.Log (or remove the line entirely) and drop the fmt import.
There was a problem hiding this comment.
Please delete it, this PR looks overall good to me.
|
cc @Monokaix |
| tierChanged := true | ||
| if exists && old.HyperNode != nil { | ||
| oldSpec := old.HyperNode.Spec | ||
| specChanged = !reflect.DeepEqual(oldSpec, hn.Spec) |
There was a problem hiding this comment.
I feel that reflect here is comparatively slow and a little overkill for a struct with 3 fields. Plus these are dependent specChanged will be true if membersChanged or tierChanged is true. I would prefer to use the k8s equality library for this instead of reflect.
oldSpec := old.HyperNode.Spec
newSpec := hn.Spec
tierChanged := oldSpec.Tier != newSpec.Tier
membersChanged := !equality.Semantic.DeepEqual(oldSpec.Members, newSpec.Members)
specChanged := tierChanged || membersChanged || oldSpec.TierName != newSpec.TierName
This is somewhat more exact.
| fmt.Printf("%v\n", hni.HyperNodesInfo()) | ||
|
|
There was a problem hiding this comment.
Please delete it, this PR looks overall good to me.
|
Thank you for your review @hajnalmt I will try to address all the comments |
Signed-off-by: Zhonghu Xu <xuzhonghu@huawei.com>
5992776 to
2f2fad4
Compare
What type of PR is this?
/kind cleanup
And also make a optimization: only rebuild when its members change
What this PR does / why we need it:
Fixes
UpdateHyperNodeto properly apply spec changes, restore regex/label rebuild behavior, and rebuild caches when members change so scheduler topology state stays consistent. Updates related tests accordingly.Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?