Skip to content

ci: auto-sync releases to Gitee repository #1616

Closed
imshubham22apr-gif wants to merge 0 commit intokmesh-net:mainfrom
imshubham22apr-gif:ci/sync-gitee
Closed

ci: auto-sync releases to Gitee repository #1616
imshubham22apr-gif wants to merge 0 commit intokmesh-net:mainfrom
imshubham22apr-gif:ci/sync-gitee

Conversation

@imshubham22apr-gif
Copy link

What type of PR is this?

/kind feature

What this PR does / why we need it:
This PR adds a GitHub Actions workflow to automatically mirror the repository to Gitee whenever a new release is published. This ensures that the Gitee mirror stays in sync with the official releases on GitHub.

Which issue(s) this PR fixes:
Fixes #134

Special notes for your reviewer:
I used wearerequired/git-mirror-action for the sync logic. To make this operational, a repository admin will need to:

  1. Generate an SSH key pair.
  2. Add the public key to the Gitee account/repository.
  3. Add the private key as a repository secret named GITEE_RSA_PRIVATE_KEY on GitHub.

Does this PR introduce a user-facing change?
NONE

NONE

@gemini-code-assist
Copy link

Summary of Changes

Hello, 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 introduces significant refactoring and testing improvements to the kmeshctl command-line tool and the Kmesh status server. It extracts common HTTP request logic from various kmeshctl command handlers into dedicated, reusable functions, enhancing code modularity and testability. Comprehensive unit tests have been added across multiple ctl packages to cover these refactored components and existing command structures. Additionally, the Kmesh status server now exposes new /debug/config_dump endpoints for Kubernetes services and authorization policies, providing richer debugging capabilities. The eBPF log reading functionality has been moved to a Linux-specific file, with a stub for other platforms, to ensure proper build behavior. Please note: The provided patch content does not align with the pull request title and description, which refer to a Gitee auto-sync CI workflow. This summary is based solely on the code changes present in the patches.

Highlights

  • Code Refactoring and Modularity: Refactored HTTP request logic in kmeshctl command handlers (authz, dump, log, monitoring) into dedicated, reusable functions, significantly improving code modularity and maintainability.
  • Enhanced Debugging Endpoints: Introduced new /debug/config_dump endpoints in the Kmesh status server to expose detailed information about Kubernetes services and authorization policies, aiding in system introspection and troubleshooting.
  • Comprehensive Unit Testing: Added extensive unit tests for various kmeshctl subcommands and their newly extracted helper functions across multiple ctl packages, ensuring robustness and correctness.
  • Platform-Specific eBPF Logging: Migrated eBPF-specific log reading functionality to a Linux-specific file (pkg/logger/logger_linux.go) and provided a stub for other operating systems, ensuring proper build behavior and cross-platform compatibility.
  • Improved kmeshctl secret Initialization: Adjusted the ctl/secret command to initialize the Kubernetes client on demand within specific functions rather than globally, enhancing resource management.

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

Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/sync-gitee.yml
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.


Code refactored, Tests now stand, strong and true, Bugs flee in fear.

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

The pull request primarily focuses on improving error handling, modularity, and testability across several ctl commands, and expanding debug capabilities. Specifically, HTTP request logic in ctl/authz, ctl/dump, and ctl/monitoring was refactored into dedicated functions that return errors, enhancing error propagation and testability. The ctl/log command was updated to use cobra.Command.RunE for better error handling and to print output to cmd.OutOrStdout(). New test files were introduced for authz, common, dump, log, monitoring, secret, and waypoint commands. The eBPF log reader was moved to a Linux-specific build file, with a stub for other platforms. Furthermore, new debug endpoints were added to pkg/status/status_server.go for dumping K8s services and authorization policies, accompanied by new tests. A review comment highlighted an improvement opportunity in ctl/dump/dump.go to replace os.Exit(1) with returning an error for more graceful error handling and improved modularity.

ctl/dump/dump.go Outdated
Comment on lines 95 to 96
log.Error(err)
os.Exit(1)

Choose a reason for hiding this comment

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

high

The use of os.Exit(1) here prevents the calling function from handling the error gracefully. It's generally better to return the error so that the caller can decide how to manage the application's exit or recovery. This improves the modularity and testability of the RunDump function.

Suggested change
log.Error(err)
os.Exit(1)
log.Error(err)
return err

Copy link

Copilot AI left a 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 pull request implements several enhancements to the Kmesh project:

  1. Status Server Endpoints: Adds two new debug endpoints (/debug/config_dump/services and /debug/config_dump/policies) for dumping K8s services and security policies known to Kmesh, with a reusable generic dumpJSON helper function.

  2. Logger Platform-Specific Refactoring: Separates the Linux-specific eBPF logging functionality from the generic logger into platform-specific files (logger_linux.go for Linux with eBPF support, and logger_stub.go for non-Linux platforms).

  3. CLI Module Refactoring: Improves error handling and testability in multiple CLI modules (ctl/log, ctl/dump, ctl/authz, ctl/monitoring) by:

    • Converting functions to return errors instead of calling exit or logging directly
    • Deferring Kubernetes client initialization to when needed (in ctl/secret)
    • Extracting helper functions for better testability
  4. Test Coverage: Adds comprehensive unit tests for newly refactored and extracted functions across multiple CLI modules and GitHub workflow automation.

  5. GitHub Workflow: Adds a new workflow to sync releases to Gitee mirror repository.

Changes:

  • Adds debug endpoints for services and policies dumps in status server
  • Refactors logger to use platform-specific build tags
  • Improves CLI error handling and testability with better function signatures
  • Defers expensive initialization until needed (Kube client in secret module)
  • Adds comprehensive test coverage for CLI modules
  • Adds GitHub workflow for Gitee synchronization

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
pkg/status/status_server.go Adds new services and policies config dump endpoints with generic dumpJSON helper
pkg/status/status_server_test.go Adds tests for new config dump endpoints
pkg/logger/logger.go Removes platform-specific code, keeps generic logger functionality
pkg/logger/logger_linux.go New file with Linux-specific eBPF logging functionality
pkg/logger/logger_stub.go New file with stub functions for non-Linux platforms
ctl/log/log.go Refactors functions to return errors and use output writers
ctl/log/log_test.go Adds test coverage for log module functions
ctl/monitoring/monitoring.go Extracts SetObservability helper and improves error handling
ctl/monitoring/monitoring_test.go Adds test coverage for monitoring functions
ctl/authz/authz.go Extracts SetAuthz and GetAuthzStatus helpers
ctl/authz/authz_test.go Adds test coverage for authz functions
ctl/dump/dump.go Extracts GetConfigDump helper function
ctl/dump/dump_test.go Adds test coverage for dump functions
ctl/secret/secret.go Defers Kube client initialization to when needed
ctl/secret/secret_test.go Adds test coverage for secret module
ctl/waypoint/waypoint_test.go Adds test coverage for waypoint module
ctl/common/common_test.go Adds test coverage for common module
.github/workflows/sync-gitee.yml New workflow for syncing to Gitee

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines 54 to 61
# Get default logger's level:
kmeshctl log <kmesh-daemon-pod> default`,
Args: cobra.MinimumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
RunGetOrSetLoggerLevel(cmd, args)
RunE: func(cmd *cobra.Command, args []string) error {
return RunGetOrSetLoggerLevel(cmd, args)
},
}
cmd.Flags().String("set", "", "Set the logger level (e.g., default:debug)")
Comment on lines +26 to +35
func TestNewCmd(t *testing.T) {
cmd := NewCmd()
if cmd.Use != "log" {
t.Fatalf("Use = %q, want %q", cmd.Use, "log")
}

if flag := cmd.Flags().Lookup("set"); flag == nil {
t.Error("set flag not registered")
}
}
Comment on lines +155 to +181
if err := SetObservability(url, observablityType); err != nil {
log.Error(err)
}
}
@kmesh-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:

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

@kmesh-bot kmesh-bot added size/XS and removed size/XL labels Mar 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use Github Actions to Automatically Sync Code Pushed to Github to Gitee

3 participants