stop populating ClusterResourceBinding with WorkloadAffinity fields#7195
Conversation
Summary of ChangesHello @zhzhuang-zju, 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 performs a cleanup by removing the population of Highlights
Changelog
Activity
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.
Pull request overview
This PR removes the WorkloadAffinity feature support specifically for ClusterResourceBinding resources, while keeping it for ResourceBinding resources. The changes align with the PR title "stop populating ClusterResourceBinding with WorkloadAffinity fields."
Changes:
- Removed WorkloadAffinityGroups population from
BuildClusterResourceBindingfunction - Removed WorkloadAffinityGroups preservation logic in
ApplyClusterPolicyfor cluster-scoped resources - Removed corresponding test cases and verification logic for ClusterResourceBinding
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| pkg/detector/detector.go | Removed WorkloadAffinityGroups population and preservation logic from ClusterResourceBinding creation and update paths |
| pkg/detector/detector_test.go | Removed test case for WorkloadAffinity with ClusterResourceBinding, removed verifyWorkloadAffinity calls for ClusterResourceBinding tests, and removed feature gate setup |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Code Review
This pull request performs a cleanup by stopping the population of WorkloadAffinityGroups in ClusterResourceBinding. This is a logical change as WorkloadAffinity is namespace-scoped and ClusterResourceBinding is for cluster-scoped resources. The implementation changes in pkg/detector/detector.go are correct. However, the test changes in pkg/detector/detector_test.go seem to have removed some valid test coverage for ResourceBindings created from a ClusterPropagationPolicy. I've added a comment with a suggestion to restore the relevant test code to prevent future regressions.
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7195 +/- ##
==========================================
- Coverage 42.05% 42.04% -0.01%
==========================================
Files 874 874
Lines 53473 53470 -3
==========================================
- Hits 22488 22484 -4
- Misses 29297 29298 +1
Partials 1688 1688
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Shall we add some notes somewhere to explain why ClusterResourceBinding does not need this?
There was a problem hiding this comment.
How about:
$ git diff pkg/apis/work/v1alpha2/binding_types.go
@@ -179,6 +179,7 @@ type ResourceBindingSpec struct {
// used to keep workloads with the same affinity group co-located or those with the same
// anti-affinity group separated across clusters. Populated by controllers, the scheduler
// consumes it for decisions.
+ // Since workload is a namespace-scoped resource, workload affinity only applies to ResourceBinding. Therefore, the WorkloadAffinityGroups field in ClusterResourceBinding will no
t be set and will not be consumed by the scheduler.
// +optional
WorkloadAffinityGroups *WorkloadAffinityGroups `json:"workloadAffinityGroups,omitempty"`
}There was a problem hiding this comment.
I'm fine with the approach that documents it on the API, just a small format suggestion:
diff --git a/pkg/apis/work/v1alpha2/binding_types.go b/pkg/apis/work/v1alpha2/binding_types.go
index cd46d0216..126630e8b 100644
--- a/pkg/apis/work/v1alpha2/binding_types.go
+++ b/pkg/apis/work/v1alpha2/binding_types.go
@@ -179,6 +179,9 @@ type ResourceBindingSpec struct {
// used to keep workloads with the same affinity group co-located or those with the same
// anti-affinity group separated across clusters. Populated by controllers, the scheduler
// consumes it for decisions.
+ // Note: Since workloads are namespace-scoped resources, workload affinity only applies to
+ // ResourceBinding. Therefore, the WorkloadAffinityGroups field in ClusterResourceBinding
+ // will not be set and will not be consumed by the scheduler.
// +optional
WorkloadAffinityGroups *WorkloadAffinityGroups `json:"workloadAffinityGroups,omitempty"`
}23bec5b to
198f41b
Compare
198f41b to
95975b4
Compare
Signed-off-by: zhzhuang-zju <m17799853869@163.com>
95975b4 to
4c9035d
Compare
RainbowMango
left a comment
There was a problem hiding this comment.
/approve
@mszacillo Do you want to take another look?
RainbowMango
left a comment
There was a problem hiding this comment.
/lgtm
@mszacillo is on a business trip this week.
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: RainbowMango The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
stop populating ClusterResourceBinding with WorkloadAffinity fields
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?: