operator pdb: fix the remaining issues
What type of PR is this? /kind cleanup
What this PR does / why we need it: Fix left comments in https://github.com/karmada-io/karmada/pull/6933
Which issue(s) this PR fixes:
Part of #6282
Special notes for your reviewer:
Does this PR introduce a user-facing change?:
Summary of Changes
Hello @zhzhuang-zju, I'm Gemini Code Assist[^1]! 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 focuses on refining the operator's handling of PodDisruptionBudgets (PDBs) by streamlining the creation of owner references for Deployments and StatefulSets. It enhances efficiency by eliminating redundant API calls to retrieve resource UIDs and improves code clarity through the introduction of standardized GVK constants and general import cleanup across various control plane components. These changes contribute to a more robust and maintainable PDB management system.
Highlights
- PDB Owner Reference Streamlining: The process of creating owner references for PodDisruptionBudgets (PDBs) has been optimized. Instead of fetching the Deployment or StatefulSet after creation/update to get its UID, the
CreateOrUpdatefunctions now directly return the updated object, which is then used to establish the owner reference. - API Client Function Signature Update: The
CreateOrUpdateDeploymentandCreateOrUpdateStatefulSetfunctions inidempotency.gohave been modified to return the created or updated Kubernetes resource object, in addition to any error encountered. This change enables more direct use of the resource's properties, such as its UID. - Standardized GroupVersionKind (GVK) Definitions: New package-level variables,
DeploymentGVKandStatefulSetGVK, have been introduced to provide standardizedGroupVersionKinddefinitions for Deployment and StatefulSet resources, promoting consistency across the codebase. - Code Cleanup and Refactoring: Unused
contextandschemaimports have been removed from several control plane component files, and thecreatePodDisruptionBudgetfunction inpdb.gohas been renamed tobuildPodDisruptionBudgetand refactored to directly return the PDB object without an error, as it no longer performs API calls.
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.
| 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 pull request 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 :thumbsup: and :thumbsdown: 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.
[^1]: 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.
:warning: Please install the to ensure uploads and comments are reliably processed by Codecov.
Codecov Report
:x: Patch coverage is 15.90909% with 37 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 46.61%. Comparing base (9ba7dc0) to head (758e7e4).
:warning: Report is 2 commits behind head on master.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| operator/pkg/util/apiclient/idempotency.go | 0.00% | 26 Missing :warning: |
| operator/pkg/controlplane/apiserver/apiserver.go | 40.00% | 0 Missing and 3 partials :warning: |
| operator/pkg/controlplane/pdb/pdb.go | 0.00% | 3 Missing :warning: |
| operator/pkg/controlplane/controlplane.go | 50.00% | 0 Missing and 1 partial :warning: |
| operator/pkg/controlplane/etcd/etcd.go | 50.00% | 0 Missing and 1 partial :warning: |
| .../pkg/controlplane/metricsadapter/metricsadapter.go | 50.00% | 0 Missing and 1 partial :warning: |
| operator/pkg/controlplane/search/search.go | 50.00% | 0 Missing and 1 partial :warning: |
| operator/pkg/controlplane/webhook/webhook.go | 50.00% | 0 Missing and 1 partial :warning: |
| :exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality. |
Additional details and impacted files
@@ Coverage Diff @@
## master #7013 +/- ##
==========================================
+ Coverage 46.60% 46.61% +0.01%
==========================================
Files 699 699
Lines 48182 48162 -20
==========================================
- Hits 22453 22449 -4
+ Misses 24032 24025 -7
+ Partials 1697 1688 -9
| Flag | Coverage Δ | |
|---|---|---|
| unittests | 46.61% <15.90%> (+0.01%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
@zhzhuang-zju Please rebase this PR as the E2E tests have been merged #7010.
~~Since https://github.com/karmada-io/karmada/pull/7010 has been merged, I will rebase to trigger the newly added e2e test.~~
@zhzhuang-zju Please rebase this PR as the E2E tests have been merged https://github.com/karmada-io/karmada/pull/7010.
Sure
/gemini review
Ready for review, cc @baiyutang @jabellard @RainbowMango
/assign
It looks good at first glance. I will review it in the next few days. Thanks.
[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
- ~~operator/OWNERS~~ [RainbowMango]
- ~~test/OWNERS~~ [RainbowMango]
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment