-
Notifications
You must be signed in to change notification settings - Fork 1k
Automated cherry pick of #6656: fixed the issue where pp-related claimMetadata was not #6705
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
Automated cherry pick of #6656: fixed the issue where pp-related claimMetadata was not #6705
Conversation
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.
Summary of Changes
Hello @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 is an automated cherry-pick of a fix from PR #6656, addressing an issue where claimMetadata associated with PropagationPolicy and ClusterPropagationPolicy was not being consistently cleaned up. The changes introduce a more robust and centralized mechanism for metadata cleanup, particularly during policy deletion or when policies are no longer active. This is achieved by refactoring existing cleanup handlers, introducing new helper functions for streamlined operations, and improving conflict resolution during updates to ensure that both resource templates and their associated bindings have their metadata removed properly.
Highlights
- Refactored Policy Deletion Handlers: The logic for handling the deletion of
PropagationPolicyandClusterPropagationPolicyhas been refactored to iterate over the policy'sResourceSelectors. This ensures that cleanup operations are more precise and only target the resources specified by the policy. - Centralized Metadata Cleanup Logic: A new helper function,
handleResourceTemplateAndBindingCleanup, has been introduced. This function centralizes the process of removingclaimMetadatafrom both the resource template and its correspondingResourceBindingorClusterResourceBinding, improving code reusability and maintainability. - Improved Conflict Resolution for Metadata Updates: The metadata cleanup functions now include robust conflict resolution mechanisms. When updating resource templates or bindings, the system will re-fetch the latest version and retry the update if a conflict occurs, ensuring data consistency.
- New Utility Functions for Resource Handling: New utility functions like
fetchResourceBinding,fetchClusterResourceBinding, andExtractUniqueNamespacedSelectorshave been added to support the refactored cleanup and policy application logic, making the process more efficient and reliable. - Enhanced Policy Application and Race Condition Handling: The policy application logic has been enhanced to prevent policies that are actively being deleted from being applied. Additionally, if a policy is unexpectedly not found, the system will now proactively trigger a metadata cleanup for the associated resource template, addressing potential race conditions.
Using Gemini Code Assist
The 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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.
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
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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 is a cherry-pick that fixes an issue with the cleanup of propagation policy-related claim metadata. The changes are robust, refactoring the deletion logic to be driven by resource selectors from the policy, which is more resilient to cache inconsistencies. The introduction of helper functions for fetching bindings with a fallback to the dynamic client, along with improved conflict handling, significantly enhances the reliability of policy management. The code correctly addresses several race conditions and edge cases. I have one minor suggestion for improving logging consistency.
| klog.Errorf("Failed to clean up claim metadata from ResourceBinding(%s/%s), error: %v", | ||
| objRef.Namespace, bindingName, err) |
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.
For consistency and to avoid potential confusion during debugging, it's better to use template.GetNamespace() in this log message, as it was the value passed to CleanupResourceBindingClaimMetadata on the preceding line. While objRef.Namespace and template.GetNamespace() are expected to be identical here, using the same variable enhances readability and maintainability.
| klog.Errorf("Failed to clean up claim metadata from ResourceBinding(%s/%s), error: %v", | |
| objRef.Namespace, bindingName, err) | |
| klog.Errorf("Failed to clean up claim metadata from ResourceBinding(%s/%s), error: %v", | |
| template.GetNamespace(), bindingName, err) |
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## release-1.12 #6705 +/- ##
================================================
- Coverage 46.65% 46.58% -0.08%
================================================
Files 665 665
Lines 54928 55053 +125
================================================
+ Hits 25629 25644 +15
- Misses 27667 27777 +110
Partials 1632 1632
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:
|
…ed up Signed-off-by: zhzhuang-zju <[email protected]>
a94fede to
a2ce1f5
Compare
XiShanYongYe-Chang
left a comment
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.
/lgtm
/approve
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: XiShanYongYe-Chang 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 |
Cherry pick of #6656 on release-1.12.
#6656: fixed the issue where pp-related claimMetadata was not
For details on the cherry pick process, see the cherry pick requests page.