-
Notifications
You must be signed in to change notification settings - Fork 57
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(logging): separate methods for internal and SPDK logging setting #726
base: master
Are you sure you want to change the base?
Conversation
WalkthroughThe pull request introduces modifications to the logging functionality within the Changes
Assessment against linked issues
Possibly related PRs
Suggested reviewers
Warning Rate limit exceeded@james-munson has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 14 minutes and 43 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. Warning There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure. 🔧 golangci-lint (1.62.2)level=warning msg="[runner] Can't run linter goanalysis_metalinter: buildir: failed to load package qcow: could not load export data: no export data for "github.com/longhorn/longhorn-engine/pkg/qcow"" 📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this 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
🧹 Outside diff range and nitpick comments (3)
pkg/instance/log.go (3)
Line range hint
46-53
: LGTM! Consider enhancing the documentation.The implementation correctly separates the instance-manager logging from SPDK logging. The method is well-structured and handles errors appropriately.
Consider adding a code example in the comment to show the expected log level format:
-// This method is used to set instance-manager internal log level regardless of engine type. +// This method is used to set instance-manager internal log level regardless of engine type. +// Example: req.Level should be one of "debug", "info", "warn", "error", etc.
Line range hint
46-70
: Consider future logging enhancements.The current implementation successfully separates instance-manager and SPDK logging. For future improvements, consider:
- Adding metrics/monitoring for log level changes
- Implementing a mechanism to persist log level settings across restarts
- Adding an audit trail for logging configuration changes
This would further enhance the logging management capabilities requested in issue #6702.
Add validation for SPDK log levels.
Based on the SPDK client implementation, we should validate the log levels before making the SPDK client call. The supported SPDK log levels are: "disabled", "error", "warn", "notice", "info", "debug" (default is "notice").
func (ops V2DataEngineInstanceOps) LogSetLevel(ctx context.Context, req *rpc.LogSetLevelRequest) (resp *emptypb.Empty, err error) { spdkLevel := strings.ToUpper(req.Level) + // Validate SPDK log levels + validLevels := map[string]bool{ + "DISABLED": true, + "ERROR": true, + "WARN": true, + "NOTICE": true, + "INFO": true, + "DEBUG": true, + } + if !validLevels[spdkLevel] { + return nil, grpcstatus.Errorf(grpccodes.InvalidArgument, "invalid SPDK log level: %s. Supported levels are: disabled, error, warn, notice, info, debug", req.Level) + } c, err := spdkclient.NewSPDKClient(ops.spdkServiceAddress)🔗 Analysis chain
Line range hint
55-70
: Add validation for SPDK log levels.While the implementation correctly handles the SPDK log level setting, it would be beneficial to validate the input before making the SPDK client call.
Consider adding validation:
func (ops V2DataEngineInstanceOps) LogSetLevel(ctx context.Context, req *rpc.LogSetLevelRequest) (resp *emptypb.Empty, err error) { spdkLevel := strings.ToUpper(req.Level) + // Validate SPDK log levels + validLevels := map[string]bool{ + "ERROR": true, + "WARN": true, + "INFO": true, + "DEBUG": true, + } + if !validLevels[spdkLevel] { + return nil, grpcstatus.Errorf(grpccodes.InvalidArgument, "invalid log level for v2 data engine: %s", spdkLevel) + }Let's verify the supported SPDK log levels:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for SPDK log level definitions or usage rg -A 5 'log.*level.*spdk|spdk.*log.*level' --type cpp --type cLength of output: 65
Script:
#!/bin/bash # Let's check the SPDK client implementation to understand the log levels ast-grep --pattern 'func LogSetLevel($$$)' # Also check for any constants or documentation about log levels rg -i "log.*level" -A 5 -B 5Length of output: 135238
Script:
#!/bin/bash # Let's check the SPDK client implementation to understand the supported log levels ast-grep --pattern 'func ($name) LogSetLevel($$$)' # Also check for any SPDK log level constants or documentation rg -i "spdk.*log.*level" -A 3 -B 3Length of output: 23593
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
pkg/instance/log.go
(3 hunks)
🔇 Additional comments (1)
pkg/instance/log.go (1)
67-67
: LGTM! Improved error message clarity.
The error message now clearly indicates that this is related to the v2 data engine, which improves debuggability.
Signed-off-by: James Munson <[email protected]>
f0141ff
to
72cd9ae
Compare
Which issue(s) this PR fixes:
Issue longhorn/longhorn#6702
What this PR does / why we need it:
Separate the setting of instance-manager log level from that for v2 data engine (spdk_tgt).
Special notes for your reviewer:
Additional documentation or context