Skip to content

Conversation

@zhzhuang-zju
Copy link
Contributor

What type of PR is this?
/kind cleanup

What this PR does / why we need it:
karmadactl addons is used to install components such as karmada-descheduler and karmada-scheduler-estimator on a Karmada instance.
karmadactl deinit is used to delete an installed Karmada instance.

To better maintain related functionalities, tests for karmadactl addons and karmadactl deinit are added to the current init e2e test module.

The previous base_test workflow was:
karmadactl initkarmadactl join/unregister → a simple propagation → karmadactl unjoin/unregister.

The updated base_test workflow is now:
karmadactl initkarmadactl join/unregisterkarmadactl addons enable → a simple propagation → karmadactl addons disablekarmadactl unjoin/unregisterkarmadactl deinit.

Which issue(s) this PR fixes:

Fixes #4544

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

NONE

@karmada-bot karmada-bot added the kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. label Dec 29, 2025
@karmada-bot karmada-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Dec 29, 2025
@gemini-code-assist
Copy link

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 significantly expands the end-to-end testing capabilities for Karmada by integrating tests for the karmadactl addons and karmadactl deinit commands. The updated init e2e test module now simulates a complete operational lifecycle, including the installation and removal of Karmada components and various addons, followed by the full deinitialization of the Karmada instance. This enhancement aims to improve the reliability and maintainability of these core karmadactl functionalities.

Highlights

  • Enhanced E2E Test Coverage: New end-to-end tests have been added for the karmadactl addons and karmadactl deinit commands, ensuring comprehensive validation of these critical functionalities.
  • Updated Test Workflow: The base_test workflow now includes a full lifecycle, from karmadactl init to join/unregister, addons enable/disable, propagation testing, unjoin/unregister, and finally karmadactl deinit.
  • New Helper Function: A WaitDeploymentDisappear function was introduced in the e2e framework to reliably wait for Kubernetes Deployments to be removed, crucial for cleanup verification.
  • Addon Image Configuration: Image variables for various Karmada addons (descheduler, metrics-adapter, search, scheduler-estimator) are now defined and used, making the tests more robust and configurable.

🧠 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.

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 👍 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

  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.

@XiShanYongYe-Chang
Copy link
Member

Thanks~

Hi @mohamedawnallah, would you like to have a review?
/cc @mohamedawnallah

Copy link

@gemini-code-assist gemini-code-assist bot left a 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 e2e tests for karmadactl addons and karmadactl deinit commands, enhancing the test coverage for Karmada's lifecycle management. The changes are well-structured and logically extend the existing init e2e test suite. I've provided a couple of suggestions to improve the robustness of the test checks and fix some minor comment inconsistencies. Overall, this is a valuable addition to the project.

@codecov-commenter
Copy link

codecov-commenter commented Dec 29, 2025

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 46.56%. Comparing base (ffa0dfb) to head (1b76288).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #7054   +/-   ##
=======================================
  Coverage   46.55%   46.56%           
=======================================
  Files         700      700           
  Lines       48084    48084           
=======================================
+ Hits        22387    22389    +2     
  Misses      24013    24013           
+ Partials     1684     1682    -2     
Flag Coverage Δ
unittests 46.56% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@zhzhuang-zju
Copy link
Contributor Author

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a 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 extends the init e2e tests to cover karmadactl addons and karmadactl deinit commands, which is a great addition for improving test coverage. The overall implementation is solid. I've made a few suggestions to enhance code quality, including improving a function comment to align with the style guide and refactoring some repetitive test code into loops for better maintainability.

@mohamedawnallah
Copy link
Member

Thanks~

Hi @mohamedawnallah, would you like to have a review? /cc @mohamedawnallah

Thanks @XiShanYongYe-Chang and @zhzhuang-zju. I put it on my work queue ❤️

Relatedly, I missed some feedback from @zhzhuang-zju on that relevant PR #5446 (sorry for that). I will try to address it this week

Copy link
Member

@mohamedawnallah mohamedawnallah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love the separation of concerns done in this PR. That would be handy in addons lifecycle management

Before

graph TD
    A1[karmadactl init] --> B1[karmadactl join/unregister]
    B1 --> C1[Simple propagation]
    C1 --> D1[karmadactl unjoin/unregister]
    
    style A1 fill:#e1f5ff
Loading

After

graph TD
   A2[karmadactl init] --> B2[karmadactl join/unregister]
   B2 --> C2[karmadactl addons enable]
   C2 --> D2[Simple propagation]
   D2 --> E2[karmadactl addons disable]
   E2 --> F2[karmadactl unjoin/unregister]
   F2 --> G2[karmadactl deinit]
   
   style A2 fill:#e1f5ff
   style C2 fill:#fff4e1
   style E2 fill:#fff4e1
   style G2 fill:#ffe1e1
Loading

})
})

ginkgo.By("Disable descheduler, metrics-adapter, scheduler-estimator and search by command addons", func() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my education: is now the new Karmada workflow (apart from tests) requiring the user to disable addons before doing unjoining/unregistering? So the user supposed to get something along those lines if they do unregister operation without disabling addons (please disable addons first before unregistering) or this only limited to tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mohamedawnallah Good question! In practice, there's no strict requirement on the order between running addons disable and performing unjoin/unregister. However, the reason for this test ordering is that the scheduler-estimator addons—are tightly coupled with member clusters on a one-to-one basis. Disabling the addon first helps avoid potential issues with the scheduler-estimator’s functionality if the cluster is unjoined or unregistered prematurely.

@XiShanYongYe-Chang
Copy link
Member

Hi @mohamedawnallah, do you think the current PR can be merged now? If you agree, you can give an LGTM.

Copy link
Member

@mohamedawnallah mohamedawnallah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🚀

@karmada-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: mohamedawnallah
Once this PR has been reviewed and has the lgtm label, please assign xishanyongye-chang for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@zhzhuang-zju
Copy link
Contributor Author

Thx for your review @mohamedawnallah. Btw, nice diagram~

Comment on lines 132 to 139
ginkgo.DeferCleanup(func() {
// Unjoin the push mode cluster
cmd := framework.NewKarmadactlCommand(karmadaConfigFilePath, "", karmadactlPath, "", karmadactlTimeout,
"unjoin", "--cluster-kubeconfig", pushModeKubeConfigPath, "--cluster-context", pushModeClusterName, "--cluster-namespace", "karmada-cluster",
"--v", "4", pushModeClusterName)
_, err := cmd.ExecOrDie()
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a question I'd like to understand: If an error occurs in a subsequent step before executing the final unjoin command, will there be any residual resources?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! Now that Defer is no longer in use, there is no assurance that the cluster can complete the unjoin process. The rationale behind this change is that the E2E test concludes with a Karmada instance cleanup. Using Defer would lead to unjoin failure, given that the Karmada instance would already be gone by that stage. Any suggestions on this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that is the case, we can make the DeferCleanup as clear as possible. If an error occurs, we should not attempt to judge the error but simply print a warning log. Similarly, the deletion of Karmada instances can be handled in the same way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx, I can give it a try

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@XiShanYongYe-Chang I placed karmadactl unjoin/unregister/deinit all within defercleanup to best ensure resource cleanup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[umbrella] e2e: Publish e2e test completion tasks

5 participants