Skip to content

Conversation

luyb177
Copy link

@luyb177 luyb177 commented Sep 2, 2025

What type of PR is this?

/kind feature

What this PR does / why we need it:

E2E testing of Karmadactl init added based on #6637.

Which issue(s) this PR fixes:

Part of #6744

Does this PR introduce a user-facing change?:

Signed-off-by: luyb177 <[email protected]>

delete init.go

Signed-off-by: luyb177 <[email protected]>

format

Signed-off-by: luyb177 <[email protected]>
Signed-off-by: luyb177 <[email protected]>

fix:The format generated by the genEtcdCipherSuites function has been modified.

Signed-off-by: luyb177 <[email protected]>

The format of the environment variables in the command has been modified.

Signed-off-by: luyb177 <[email protected]>

Correct the errors reported in the CI.

Signed-off-by: luyb177 <[email protected]>

Add additional parameters in the configuration file to customize the control panel.

Signed-off-by: luyb177 <[email protected]>
Signed-off-by: luyb177 <[email protected]>

fix:Modified some function names, deleted some code comments and TODO markers.

Signed-off-by: luyb177 <[email protected]>

fix:Delete the unnecessary blank lines.

Signed-off-by: luyb177 <[email protected]>

fix:Delete the unnecessary blank lines.

Signed-off-by: luyb177 <[email protected]>
@karmada-bot
Copy link
Collaborator

@luyb177: The label(s) kind/test cannot be applied, because the repository doesn't have them.

In response to this:

What type of PR is this?

/kind test

What this PR does / why we need it:

E2E testing of Karmadactl init added based on #6637.

Special notes for your reviewer:
The successful output result of the test is:

Does this PR introduce a user-facing change?:

NONE

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@karmada-bot karmada-bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Sep 2, 2025
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.

Summary of Changes

Hello @luyb177, 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 enhances the karmadactl init command by enabling advanced customization of Karmada control plane components through extra arguments. It also introduces robust end-to-end tests to ensure the reliability of this new functionality. The changes aim to provide greater flexibility for users to fine-tune their Karmada deployments while maintaining a clean and testable codebase.

Highlights

  • E2E Testing for Karmadactl Init: Introduced comprehensive end-to-end tests for the karmadactl init command, specifically focusing on the ability to customize control plane components with extra arguments.
  • Customizable Component Arguments: Added new command-line flags and configuration fields to karmadactl init allowing users to pass arbitrary extraArgs to various Karmada control plane components, including Etcd, Karmada API Server, Scheduler, Controller Manager, Webhook, Kube Controller Manager, and Aggregated API Server.
  • Argument Merging Utility: Implemented a new utility package (pkg/karmadactl/cmdinit/utils) with a KarmadaComponentCommand function to intelligently merge default component arguments with user-provided extraArgs, ensuring proper validation and precedence.
  • Code Refactoring and Cleanup: Refactored the internal logic for generating component commands in pkg/karmadactl/cmdinit/kubernetes to leverage the new argument merging utility, simplifying the codebase and improving maintainability. This also involved updating Etcd's command generation to a direct executable call instead of a shell script.
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

  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.

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 the ability to pass extra arguments to Karmada components during karmadactl init, enhancing customization. It includes the necessary changes in command-line flags, configuration types, and deployment generation logic. The PR also adds comprehensive unit and e2e tests for the new functionality. My review focuses on improving code clarity and fixing a bug in argument parsing. I've pointed out the use of non-English comments, leftover // todo markers, and some dead code. Most importantly, I've identified a critical bug in the argument parsing logic for extra arguments and provided a suggested fix.

@codecov-commenter
Copy link

codecov-commenter commented Sep 2, 2025

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

Codecov Report

❌ Patch coverage is 65.50926% with 149 lines in your changes missing coverage. Please review.
✅ Project coverage is 45.78%. Comparing base (d410a0b) to head (4a14612).
⚠️ Report is 72 commits behind head on master.

Files with missing lines Patch % Lines
pkg/karmadactl/cmdinit/kubernetes/deploy.go 30.91% 130 Missing and 13 partials ⚠️
pkg/karmadactl/cmdinit/kubernetes/deployments.go 96.77% 2 Missing and 1 partial ⚠️
pkg/karmadactl/cmdinit/utils/merge.go 96.38% 2 Missing and 1 partial ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6728      +/-   ##
==========================================
+ Coverage   45.35%   45.78%   +0.43%     
==========================================
  Files         688      691       +3     
  Lines       57020    57532     +512     
==========================================
+ Hits        25862    26342     +480     
+ Misses      29547    29542       -5     
- Partials     1611     1648      +37     
Flag Coverage Δ
unittests 45.78% <65.50%> (+0.43%) ⬆️

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.

@luyb177 luyb177 force-pushed the e2e-3 branch 4 times, most recently from 63d9b06 to 32a29a1 Compare September 3, 2025 14:08
@karmada-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

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

@luyb177 luyb177 force-pushed the e2e-3 branch 12 times, most recently from ab70ff6 to 0caf1f1 Compare September 4, 2025 14:08
@luyb177
Copy link
Author

luyb177 commented Oct 7, 2025

/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 introduces end-to-end testing for the customized control panel of karmadactl init and adds the ability to pass extra arguments to various Karmada components. The changes are extensive, touching testing scripts, command-line definitions, configuration types, and deployment logic. Overall, the implementation is solid, but I have identified a few areas for improvement regarding code clarity, maintainability, and test correctness. My feedback includes suggestions to simplify shell scripts, fix a potential issue in the test helpers, and remove some dead code.

@luyb177
Copy link
Author

luyb177 commented Oct 9, 2025

/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 introduces a valuable feature to customize Karmada components during initialization via karmadactl init, along with comprehensive E2E tests to validate it. The implementation is solid, particularly the refactoring of command-line argument handling for Karmada components.

I've identified a few areas for improvement, mainly in the new test scripts, to enhance robustness and correctness. Please see my detailed comments below.


out := make([]string, len(args))
for i, arg := range args {
out[i] = flag + "=" + "\"" + arg + "\""

Choose a reason for hiding this comment

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

critical

The wrapArgs function incorrectly adds double quotes around the argument value. When exec.Command is used, arguments are passed directly to the process without shell interpretation. This means the quotes will be part of the argument string, causing parsing to fail downstream because the argument will be \"--foo=bar\" instead of --foo=bar.

The quotes should be removed to ensure the arguments are passed correctly to karmadactl.

Suggested change
out[i] = flag + "=" + "\"" + arg + "\""
out[i] = flag + "=" + arg

# step2: prepare and copy the newest crds for karmadactl init
# step2.1: prepare the newest crds for karmadactl init
echo "Prepare the newest crds for karmadactl init"
cd charts/karmada/

Choose a reason for hiding this comment

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

medium

For robustness, it's better to use an absolute path constructed from ${REPO_ROOT} to avoid issues with the script's execution directory. This makes the script less dependent on the current working directory.

Suggested change
cd charts/karmada/
cd "${REPO_ROOT}"/charts/karmada/

echo "Prepare the newest crds for karmadactl init"
cd charts/karmada/
cp -r _crds crds
tar -zcvf ../../crds.tar.gz crds

Choose a reason for hiding this comment

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

medium

The temporary crds directory created by cp -r _crds crds is not removed after the tarball is created. This leaves artifacts in the source tree. It's good practice to clean up temporary files and directories.

Suggested change
tar -zcvf ../../crds.tar.gz crds
tar -zcvf ../../crds.tar.gz crds
rm -rf crds

# step2.3: Copy the local crds.tar.gz file to the specified path
DATA_DIR="${HOME}/karmada-data"
mkdir -p "${DATA_DIR}"
cp ./crds.tar.gz "${DATA_DIR}/crds.tar.gz"

Choose a reason for hiding this comment

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

medium

The crds.tar.gz file is left in the repository root after being copied. It should be cleaned up to avoid polluting the source tree.

Suggested change
cp ./crds.tar.gz "${DATA_DIR}/crds.tar.gz"
cp ./crds.tar.gz "${DATA_DIR}/crds.tar.gz"
rm ./crds.tar.gz

…e use of extraArgs in each component. Modify the functions in merge.go to resolve issues such as leading and trailing spaces in the command line.

Signed-off-by: luyb177 <[email protected]>

feat:Add a performance testing function that adds capacity to each slice to avoid multiple memory allocations.

Signed-off-by: luyb177 <[email protected]>

fix:Modified the format of additional parameters in the configuration file

Signed-off-by: luyb177 <[email protected]>

fix:Modification based on comments

Signed-off-by: luyb177 <[email protected]>

fix:Streamline and optimize PR

Signed-off-by: luyb177 <[email protected]>

feat:Add test files. In the Example, add detailed explanations for the use of extraArgs in each component. Modify the functions in merge.go to resolve issues such as leading and trailing spaces in the command line.

Signed-off-by: luyb177 <[email protected]>

feat:Add a performance testing function that adds capacity to each slice to avoid multiple memory allocations.

Signed-off-by: luyb177 <[email protected]>

fix:Modified the format of additional parameters in the configuration file

Signed-off-by: luyb177 <[email protected]>

fix:Modification based on comments

Signed-off-by: luyb177 <[email protected]>

fix:Streamline and optimize PR

Signed-off-by: luyb177 <[email protected]>

feat:Add test files. In the Example, add detailed explanations for the use of extraArgs in each component. Modify the functions in merge.go to resolve issues such as leading and trailing spaces in the command line.

Signed-off-by: luyb177 <[email protected]>

feat:Add a performance testing function that adds capacity to each slice to avoid multiple memory allocations.

Signed-off-by: luyb177 <[email protected]>

fix:Modified the format of additional parameters in the configuration file

Signed-off-by: luyb177 <[email protected]>

fix:Modification based on comments

Signed-off-by: luyb177 <[email protected]>

fix:Modified the logic for accepting configuration files.

Signed-off-by: luyb177 <[email protected]>
Signed-off-by: luyb177 <[email protected]>
Signed-off-by: luyb177 <[email protected]>

fix: add execute permission to init-e2e-environment.sh

Signed-off-by: luyb177 <[email protected]>

fix:Modified the locations of some environment variables.

Signed-off-by: luyb177 <[email protected]>

fix:Modify the paths of crds and karmadactl.

Signed-off-by: luyb177 <[email protected]>

fix:Fix the error that prevents it from running on Linux.

Signed-off-by: luyb177 <[email protected]>

Revert "fix:Modify the paths of crds and karmadactl."

This reverts commit cb269d8.

Signed-off-by: luyb177 <[email protected]>

fix:Modify the path.

Signed-off-by: luyb177 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants