-
Notifications
You must be signed in to change notification settings - Fork 1k
Add dependency policy event: DependencyPolicyConflict #6795
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
Conversation
|
Welcome @Kexin2000! It looks like this is your first PR to karmada-io/karmada 🎉 |
Summary of ChangesHello @Kexin2000, 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 significantly improves the stability and predictability of resource management in Karmada by addressing issues related to multi-path distribution. It enhances the system's ability to communicate dependency policy states through new event reasons and rectifies a behavioral flaw where dependency mechanisms could inadvertently override explicitly defined resource binding configurations. These changes collectively aim to prevent field flapping and ensure that explicit policies are respected, leading to more robust and understandable resource propagation. Highlights
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances the dependency distribution mechanism in Karmada by adding observability events and preventing field overrides on explicitly governed ResourceBindings. The changes address issues with multi-path distribution causing field flapping and unpredictable behavior.
- Adds three new event reasons for better visibility into dependency policy conflicts and aggregation
- Modifies dependency controller to respect explicit policy ownership of ResourceBindings
- Prevents overwriting of ConflictResolution and PreserveResourcesOnDeletion fields when ResourceBindings are governed by PropagationPolicy or ClusterPropagationPolicy
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pkg/events/events.go | Adds three new event reason constants for dependency policy handling |
| pkg/dependenciesdistributor/dependencies_distributor.go | Updates binding update logic to conditionally set fields and emit warning events |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
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.
Code Review
This pull request introduces new events for dependency policies and prevents the dependency distributor from overwriting fields on ResourceBindings that are managed by an explicit policy. The changes are logical and address the intended issue. However, I've found one issue with the implementation of the new warning event, which could lead to excessive event logging. My review includes a suggestion to refine the condition for firing this event to make it more meaningful and less noisy.
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6795 +/- ##
==========================================
+ Coverage 45.82% 46.28% +0.46%
==========================================
Files 690 693 +3
Lines 57242 47249 -9993
==========================================
- Hits 26231 21871 -4360
+ Misses 29384 23721 -5663
- Partials 1627 1657 +30
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:
|
|
If the PR is ready, remember to cc me. |
d720532 to
1efab6c
Compare
59d702b to
40cfc94
Compare
|
Hi @XiShanYongYe-Chang, the PR is now ready for review. Please take a look when you are free. 😃 This PR only adds the new event. The changes to the conflict field aggregation logic are in a separate PR #6796. |
Good. /assign |
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.
Code Review
This pull request introduces a new event, DependencyPolicyConflict, to enhance observability for dependency policy conflicts in Karmada. It modifies the createOrUpdateAttachedBinding function to detect conflicts in ConflictResolution and PreserveResourcesOnDeletion settings, emitting a warning event when discrepancies are found. Additionally, the pull request includes corresponding unit tests to validate the new functionality. No style guide was provided, so the review focuses on correctness and code clarity.
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~
|
/gemini review |
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.
Code Review
This pull request introduces a new DependencyPolicyConflict event to improve observability when multiple resources define conflicting dependency policies. The implementation correctly identifies conflicts in ConflictResolution and PreserveResourcesOnDeletion for dependency-generated resource bindings and emits a warning event. The changes are well-tested. I've provided a few suggestions to improve code quality, performance, and conciseness.
|
/gemini review |
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.
Code Review
This pull request introduces a new DependencyPolicyConflict event to provide observability into conflicting dependency policies. The implementation adds new logic to detect conflicts in ConflictResolution and PreserveResourcesOnDeletion settings from different ResourceBindings. The changes are well-tested with a new unit test to verify event emission.
My review focuses on improving the efficiency of the new conflict detection logic and adhering to best practices for context propagation. I've suggested merging the two conflict detection functions into one to reduce redundant API calls. I also pointed out the use of context.TODO() and a minor issue with a copyright year.
0f9ed1b to
94db2de
Compare
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~
/lgtm
/cc @RainbowMango
Signed-off-by: Kexin2000 <3299133282@qq.com>
|
/lgtm |
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.
/assign
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.
/approve
|
[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
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
/kind feature
What this PR does / why we need it:
Adds observability for dependency policy conflicts. When multiple independent resources define divergent policies on the same dependent resource, Karmada now emits a single warning event to surface the behavior.
Which issue(s) this PR fixes:
Fixes #6000
Part of #6803
Special notes for your reviewer:
Adds the following event reason in
pkg/events/events.go:DependencyPolicyConflict: emitted when a dependency policy conflict is detected.Updates
createOrUpdateAttachedBindinginpkg/dependenciesdistributor/dependencies_distributor.goto:Spec.Placement == nilas dependency-generated:DependencyPolicyConflict).Spec.Placement != nil), leaveSpec.ConflictResolutionunchangedDoes this PR introduce a user-facing change?: