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

feat: implement MetricsGet to support V1 and V2 data engines in ProxyOps #899

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hookak
Copy link

@hookak hookak commented Feb 26, 2025

Which issue(s) this PR fixes:

longhorn/longhorn#10472

What this PR does / why we need it:

Special notes for your reviewer:

Additional documentation or context

Copy link

coderabbitai bot commented Feb 26, 2025

Walkthrough

The changes update the metrics retrieval functionality across both client and proxy components. The client’s MetricsGet function now accepts an additional dataEngine parameter with corresponding validation logic, ensuring that the requested data engine is supported. At the proxy level, metrics retrieval is enhanced with extra logging, conditional routing based on the data engine, and dedicated methods for V1 and V2 engines. The ProxyOps interface is extended to include this new MetricsGet method.

Changes

File(s) Change Summary
pkg/client/proxy_metrics.go Modified MetricsGet signature to add dataEngine as the first parameter; updated parameter mapping and added validation for dataEngine; populates the DataEngine field in the request.
pkg/proxy/metrics.go Enhanced MetricsGet in the Proxy struct with additional logging (adding volume, instance, and dataEngine); added checks to route requests to new V1 and V2 metrics methods with appropriate error handling.
pkg/proxy/proxy.go Extended the ProxyOps interface by adding a new MetricsGet(context.Context, *rpc.ProxyEngineRequest) (*rpc.EngineMetricsGetProxyResponse, error) method.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant ProxyClient
    participant Proxy
    participant V1Ops
    participant V2Ops

    Client->>ProxyClient: MetricsGet(dataEngine, engineName, volumeName, serviceAddress)
    ProxyClient->>Proxy: Create and validate request with dataEngine
    Proxy->>Proxy: Validate dataEngine in ops map
    alt Data engine is V1
        Proxy->>V1Ops: MetricsGet(request)
        V1Ops-->>Proxy: Return metrics
    else Data engine is V2
        Proxy->>V2Ops: MetricsGet(request)
        V2Ops-->>Proxy: Return metrics
    end
    Proxy-->>ProxyClient: Return aggregated metrics
    ProxyClient-->>Client: Metrics
Loading

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Free

📥 Commits

Reviewing files that changed from the base of the PR and between dad5e5e and 5ec21dd.

📒 Files selected for processing (3)
  • pkg/client/proxy_metrics.go (2 hunks)
  • pkg/proxy/metrics.go (2 hunks)
  • pkg/proxy/proxy.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/proxy/proxy.go

Note

🎁 Summarized by CodeRabbit Free

Your organization has reached its limit of developer seats under the Pro Plan. For new users, CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please add seats to your subscription by visiting https://app.coderabbit.ai/login.If you believe this is a mistake and have available seats, please assign one to the pull request author through the subscription management page using the link above.

🪧 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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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

@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

🧹 Nitpick comments (3)
pkg/client/proxy_metrics.go (2)

9-9: Parameter expansion in function signature.

Adding dataEngine to the MetricsGet parameters is a coherent way to support multiple engine variants. Consider adding doc comments for clarity, indicating the valid values and usage of the dataEngine parameter.


20-23: Data engine validation.

Great job verifying that the provided dataEngine corresponds to a valid enum. If getDataEngine(dataEngine) might be case-sensitive, consider normalizing or clarifying expectations to prevent unexpected user input errors.

pkg/proxy/metrics.go (1)

54-76: Implementation for V2 engine metrics retrieval.

Fetching a specialized SPDK client for the engine address aligns well with the V2 approach. The error handling with grpcstatus.Errorf(grpccodes.Internal, ...) is also consistent. Consider caching or pooling SPDK clients if performance or connection overhead becomes a concern under heavy load.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 750c0a4 and 8a97c4e.

📒 Files selected for processing (3)
  • pkg/client/proxy_metrics.go (2 hunks)
  • pkg/proxy/metrics.go (2 hunks)
  • pkg/proxy/proxy.go (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Summary
🔇 Additional comments (6)
pkg/proxy/proxy.go (1)

55-56: New interface method for metrics retrieval added.

Including a MetricsGet method in ProxyOps aligns with the existing design pattern, ensuring that metrics retrieval is formally part of the proxy operations. Please verify that all concrete implementations of this interface are tested to maintain coverage for your new feature.

pkg/client/proxy_metrics.go (2)

4-6: Import changes appear correct.

The addition of "fmt" and "github.com/pkg/errors" is consistent with the usage below. No concerns here.


14-14: New map entry for dataEngine.

This entry harmonizes with the existing parameter validations. Looks good.

pkg/proxy/metrics.go (3)

15-20: Enhanced logging with more context.

Including dataEngine and other fields provides valuable insights for debugging. Consider adding log levels or additional correlation information if deeper tracing is needed.


23-28: Data engine routing check.

Returning Unimplemented when req.DataEngine is missing in the operations map is a clear, explicit way to indicate unsupported engines. This is well-handled and maintains a clean architecture.


30-52: Implementation for V1 engine metrics retrieval.

Creating a new controller client, fetching metrics, and closing it is straightforward. Ensure concurrency scenarios are handled properly if multiple requests come in at once, though the current approach of opening/closing clients on demand is typically acceptable. Looks good overall.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant