Log plugin RPC operations and connections#71
Conversation
WalkthroughRPC connection handling now logs accept and close events, and RPCServerDriver methods now emit structured logs with operation names and selected metadata. The deadcode linter entry is removed, and two UpdateConfigRaw parameters are marked intentionally unused. ChangesRPC Logging and Cleanup
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant http.Serve
participant loggingListener
participant loggingConn
participant TCPListener
http.Serve->>loggingListener: Accept()
loggingListener->>TCPListener: Accept connection
loggingListener->>loggingConn: wrap accepted connection
loggingConn->>loggingConn: Close() logs remote address and duration
sequenceDiagram
participant RPCServerDriver
participant logRPC
participant ActualDriver
RPCServerDriver->>logRPC: record method name and machine name
RPCServerDriver->>ActualDriver: delegate method call
ActualDriver-->>RPCServerDriver: return result
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| - gofmt | ||
| - gosec | ||
| - gocritic | ||
| - deadcode |
There was a problem hiding this comment.
Is unused enabled by defaut?
For what it’s worth, this golangci-lint config is a v1 config while upstream has moved on to v2. Not sure it’s worth switching to v2 though…
There was a problem hiding this comment.
yes, unused is enabled by default.
If we move to a v2 config, there are many linter errors that need to be fixed. Might be worth creating a different PR for it.
| } | ||
|
|
||
| func (r *RPCServerDriver) DriverName(_ *struct{}, reply *string) error { | ||
| r.logRPC("DriverName", log.DebugLevel, nil) |
There was a problem hiding this comment.
How did you decide between the various log levels?
There was a problem hiding this comment.
I changed them back to Info for consistency.
Signed-off-by: Gunjan Vyas <vyasgun20@gmail.com>
Signed-off-by: Gunjan Vyas <vyasgun20@gmail.com>
f4384e8 to
14e8db9
Compare
|
@vyasgun I replaced the |
|
@anjannath you'll also need to replace the reference in |
This PR also fixes linter warnings and deprecations
How to test:
Checkout the PR branch
Update machine-driver-libvirt
Update CRC
cd ../crc go mod edit -replace=github.com/crc-org/machine=../machine go mod vendor make clean makeClean up and start fresh
Verify RPC logging
Start CRC and verify that RPC operations and connections are logged in
~/.crc/crc.log:grep RPC ~/.crc/crc.logLogs visible in
~/.crc/crc.logas follows:Summary by CodeRabbit