Skip to content
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

fix: kube client when have multiple kubeconfig and fix stop port forward #293

Merged
merged 3 commits into from
Aug 26, 2024

Conversation

hcavarsan
Copy link
Owner

@hcavarsan hcavarsan commented Aug 25, 2024

fix: try to create client it using openssl, if error try using the rust-tls
relates: #289

fix: fix client and logic to stop port
relates: #292

@hcavarsan hcavarsan added the dependencies Pull requests that update a dependency file label Aug 25, 2024
@hcavarsan hcavarsan self-assigned this Aug 25, 2024
Copy link
Contributor

coderabbitai bot commented Aug 25, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The changes involve refactoring the create_client_with_specific_context function in src/client.rs, introducing new helper functions for improved structure and error handling. Additionally, the client creation logic in stop_all_port_forward, deploy_and_forward_pod, and stop_proxy_forward functions in src/core.rs was modified to utilize the new client creation process, enhancing error handling and robustness of the code. Furthermore, the config_id parameter type was changed from String to i64 in several functions.

Changes

Files Change Summary
crates/kftray-portforward/src/client.rs Refactored create_client_with_specific_context; added new helper functions for kubeconfig path retrieval and client configuration; improved error handling and logging.
crates/kftray-portforward/src/core.rs Updated client creation logic in stop_all_port_forward, deploy_and_forward_pod, and stop_proxy_forward to use create_client_with_specific_context, enhancing error handling.
crates/kftray-tauri/src/commands/portforward.rs Changed config_id parameter type from String to i64 in stop_proxy_forward_cmd, adding error handling for parsing.
crates/kftui/src/core/port_forward.rs Modified argument handling in stop_port_forwarding to pass config.id.unwrap_or_default() directly to stop_proxy_forward.
crates/kftray-commons/src/utils/validate_configs.rs Introduced generic type parameter R: Runtime to show_alert_dialog and alert_multiple_configs functions for enhanced flexibility.
docs/kftray/INSTALL.md Updated download links to reflect version increment from 0.13.2 to 0.13.3 across all platforms.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Client
    participant KubeconfigManager

    User->>Client: create_client_with_specific_context(kubeconfig, context_name)
    Client->>KubeconfigManager: get_kubeconfig_paths_from_option(kubeconfig)
    KubeconfigManager-->>Client: return kubeconfig paths
    Client->>KubeconfigManager: create_config_with_context(kubeconfig, context_name)
    KubeconfigManager-->>Client: return Config
    Client->>Client: create_client_with_config(Config)
    Client-->>User: return Option<Client>
Loading

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 494d775 and cbb7b4c.

Files ignored due to path filters (3)
  • Cargo.lock is excluded by !**/*.lock, !**/*.lock
  • crates/kftray-portforward/Cargo.toml is excluded by !**/*.toml
  • crates/kftray-tauri/Cargo.toml is excluded by !**/*.toml
Files selected for processing (1)
  • crates/kftray-portforward/src/client.rs (3 hunks)
Additional comments not posted (5)
crates/kftray-portforward/src/client.rs (5)

Line range hint 12-78: LGTM!

The function is well-structured with improved error handling and logging. The fallback mechanism to use Rustls if OpenSSL fails enhances robustness.

The code changes are approved.


80-95: LGTM!

The function effectively handles different scenarios for retrieving kubeconfig paths.

The code changes are approved.


97-111: LGTM!

The function is correctly implemented with informative logging.

The code changes are approved.


113-153: LGTM!

The function is well-structured with improved error handling and logging. The fallback mechanism to use Rustls if OpenSSL fails enhances robustness.

The code changes are approved.


Line range hint 154-158: LGTM!

The function is correctly implemented and straightforward.

The code changes are approved.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between cbb7b4c and 78dbd56.

Files selected for processing (2)
  • crates/kftray-portforward/src/client.rs (3 hunks)
  • crates/kftray-portforward/src/core.rs (4 hunks)
Additional comments not posted (10)
crates/kftray-portforward/src/client.rs (7)

18-22: LGTM!

The logging improvements are clear and informative.

The code changes are approved.


28-32: LGTM!

The refactoring improves readability and modularity.

The code changes are approved.


Line range hint 35-50: LGTM!

The logging improvements are clear and informative.

The code changes are approved.


56-84: LGTM!

The error handling and logging improvements are clear and informative.

The code changes are approved.


95-110: LGTM!

The new helper function get_kubeconfig_paths_from_option is well-structured and improves modularity.

The code changes are approved.


112-123: LGTM!

The new helper function create_config_with_context is well-structured and improves modularity.

The code changes are approved.


125-165: LGTM!

The new helper function create_client_with_config is well-structured and improves modularity. The fallback mechanism for OpenSSL and Rustls is implemented correctly.

The code changes are approved.

crates/kftray-portforward/src/core.rs (3)

260-267: LGTM!

The new client creation process enhances error handling and robustness.

The code changes are approved.


566-568: LGTM!

The new client creation process enhances error handling and robustness.

The code changes are approved.


700-707: LGTM!

The new client creation process enhances error handling and robustness.

The code changes are approved.

@hcavarsan hcavarsan changed the title fix: try to create client it using openssl, if error try using the rust-tls fix: kube client when have multiple kubeconfig and fix stop port forward Aug 26, 2024
@hcavarsan hcavarsan merged commit 3c6e8af into main Aug 26, 2024
7 checks passed
@hcavarsan hcavarsan deleted the fix-start-forward-old branch September 27, 2024 00:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant