Skip to content

Thinpool gRPC Call And Monitor#58

Open
Zllinc wants to merge 4 commits into
lingdie:devbox-daemon-v2from
Zllinc:thinpool
Open

Thinpool gRPC Call And Monitor#58
Zllinc wants to merge 4 commits into
lingdie:devbox-daemon-v2from
Zllinc:thinpool

Conversation

@Zllinc
Copy link
Copy Markdown

@Zllinc Zllinc commented Sep 4, 2025

No description provided.

type NodeStatsProvider interface {
ContainerFsStats(ctx context.Context) (FsStats, error)
ThinPoolMetrics() ([]*ThinPoolMetrics, error)
ExportToVictoriaMetrics([]*ThinPoolMetrics) error
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Metrics exporting should be done in lvm thin pool monitor?

Copy link
Copy Markdown
Collaborator

@dinoallo dinoallo left a comment

Choose a reason for hiding this comment

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

Currently, the implementation of NodeStatsProviderImpl is coupled with LVM. Please make devbox controller as storage agnostic as possible, i.e. remove any logic related to LVM. Instead, you should implement NodeStatsProviderImpl in LVM monitor. NodeStats should only contain the information required for scheduling pods.

@dinoallo
Copy link
Copy Markdown
Collaborator

dinoallo commented Sep 4, 2025

Also, the linting check has failed.

Copy link
Copy Markdown

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 PR implements "Thinpool gRPC Call And Monitor" functionality for the devbox controller, transitioning from v1alpha1 to v1alpha2 API version and introducing comprehensive LVM thin pool monitoring with gRPC communication and VictoriaMetrics integration.

Key changes include:

  • Complete API version migration from v1alpha1 to v1alpha2 with new devbox state management and commit recording system
  • Implementation of LVM monitoring service with gRPC server/client architecture for thin pool metrics collection
  • Addition of VictoriaMetrics integration for metrics export and monitoring dashboard support

Reviewed Changes

Copilot reviewed 54 out of 57 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
service/go.work.sum Added dependencies for Alipay SDK and cenkalti/backoff package updates
controllers/devbox/internal/stat/ New LVM monitoring system with gRPC services, clients, and VictoriaMetrics integration
controllers/devbox/internal/controller/ Major refactor to v1alpha2 API with new state management, scheduling logic, and registry utilities
controllers/devbox/internal/commit/ New commit system implementation with containerd integration for image management
controllers/devbox/api/v1alpha2/ New API version with updated devbox resource definitions and state management
controllers/devbox/config/ Updated RBAC, samples, and deployment manifests for v1alpha2

Comment on lines +17 to +18
fmt.Printf("=== Thin Pool Metrics Test Results ===\n")
fmt.Printf("Total thin pools found: %d\n", len(metrics))
Copy link

Copilot AI Sep 5, 2025

Choose a reason for hiding this comment

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

The test functions TestCollectThinPoolMetrics and TestExportToVictoriaMetrics contain duplicated code for printing test results. Consider extracting this into a helper function to reduce code duplication.

Copilot uses AI. Check for mistakes.
Comment on lines +49 to +50
fmt.Printf("=== Thin Pool Metrics Test Results ===\n")
fmt.Printf("Total thin pools found: %d\n", len(metrics))
Copy link

Copilot AI Sep 5, 2025

Choose a reason for hiding this comment

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

The test functions TestCollectThinPoolMetrics and TestExportToVictoriaMetrics contain duplicated code for printing test results. Consider extracting this into a helper function to reduce code duplication.

Copilot uses AI. Check for mistakes.
Comment on lines +300 to +301
// todo : delete data and save length
logger.Info("[exportToVictoriaMetrics] Sending %d metrics to VM:\n%s\n", len(allPrometheusData), data)
Copy link

Copilot AI Sep 5, 2025

Choose a reason for hiding this comment

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

The TODO comment indicates that logging the full data should be removed and only the length should be saved. This could expose sensitive information in logs and should be addressed.

Suggested change
// todo : delete data and save length
logger.Info("[exportToVictoriaMetrics] Sending %d metrics to VM:\n%s\n", len(allPrometheusData), data)
// Only log the count and size of metrics, not the full data to avoid exposing sensitive information
logger.Info("[exportToVictoriaMetrics] Sending %d metrics to VM (total size: %d bytes)", len(allPrometheusData), len(data))

Copilot uses AI. Check for mistakes.
}

func RegisterLVMMonitorServiceServer(s grpc.ServiceRegistrar, srv LVMMonitorServiceServer) {
// If the following call pancis, it indicates UnimplementedLVMMonitorServiceServer was
Copy link

Copilot AI Sep 5, 2025

Choose a reason for hiding this comment

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

There's a typo in the comment: 'pancis' should be 'panics'.

Suggested change
// If the following call pancis, it indicates UnimplementedLVMMonitorServiceServer was
// If the following call panics, it indicates UnimplementedLVMMonitorServiceServer was

Copilot uses AI. Check for mistakes.
Comment on lines +127 to +129
// test:
for _, metric := range metrics {
fmt.Printf("Client metric: %+v\n", *metric)
Copy link

Copilot AI Sep 5, 2025

Choose a reason for hiding this comment

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

Debug code with fmt.Printf statements should be removed from production code or replaced with proper logging.

Suggested change
// test:
for _, metric := range metrics {
fmt.Printf("Client metric: %+v\n", *metric)
logger.Debug("Client metric: %+v", *metric)

Copilot uses AI. Check for mistakes.
Comment on lines +889 to +890
// TODO: check if this could lead to overflow
totalCPULimit += cpuLimit.Value()
Copy link

Copilot AI Sep 5, 2025

Choose a reason for hiding this comment

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

Multiple TODO comments indicate potential overflow issues in resource calculation. These should be addressed by implementing proper overflow checks or using appropriate data types.

Copilot uses AI. Check for mistakes.
Comment on lines +920 to +921
// TODO: check if this could lead to overflow
totalMemoryRequest += memReq.Value()
Copy link

Copilot AI Sep 5, 2025

Choose a reason for hiding this comment

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

Multiple TODO comments indicate potential overflow issues in resource calculation. These should be addressed by implementing proper overflow checks or using appropriate data types.

Copilot uses AI. Check for mistakes.
Comment on lines +951 to +952
// TODO: check if this could lead to overflow
totalMemoryLimit += memLimit.Value()
Copy link

Copilot AI Sep 5, 2025

Choose a reason for hiding this comment

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

Multiple TODO comments indicate potential overflow issues in resource calculation. These should be addressed by implementing proper overflow checks or using appropriate data types.

Copilot uses AI. Check for mistakes.
if username == "" && secret == "" {
hostOptions.Credentials = nil
} else {
// TODO: fix this, use flags or configs to set mulit registry credentials
Copy link

Copilot AI Sep 5, 2025

Choose a reason for hiding this comment

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

There's a typo in the comment: 'mulit' should be 'multi'.

Suggested change
// TODO: fix this, use flags or configs to set mulit registry credentials
// TODO: fix this, use flags or configs to set multi registry credentials

Copilot uses AI. Check for mistakes.
}
}

// todo: implement the schedule logic to replace the current logic
Copy link

Copilot AI Sep 5, 2025

Choose a reason for hiding this comment

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

This TODO comment indicates incomplete scheduling logic implementation. The comment should be more specific about what needs to be implemented or removed if the logic is complete.

Suggested change
// todo: implement the schedule logic to replace the current logic

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Sep 8, 2025

We require pull request titles to follow the Conventional Commits specification and it looks like your proposed title needs to be adjusted.

Details:

No release type found in pull request title "Thinpool gRPC Call And Monitor". Add a prefix to indicate what kind of release this pull request corresponds to. For reference, see https://www.conventionalcommits.org/

Available types:
 - feat
 - fix
 - docs
 - style
 - refactor
 - perf
 - test
 - build
 - ci
 - chore
 - revert

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.

4 participants