Skip to content

Log plugin RPC operations and connections#71

Open
vyasgun wants to merge 2 commits into
crc-org:masterfrom
vyasgun:pr/operation-logs
Open

Log plugin RPC operations and connections#71
vyasgun wants to merge 2 commits into
crc-org:masterfrom
vyasgun:pr/operation-logs

Conversation

@vyasgun

@vyasgun vyasgun commented Jun 29, 2026

Copy link
Copy Markdown

This PR also fixes linter warnings and deprecations

Logs visible in ~/.crc/crcd.log as follows:

grep RPC ~/.crc/crcd.log
time="2026-06-29T16:13:47+05:30" level=debug msg="() DBG | time=\"2026-06-29T16:13:47+05:30\" level=info msg=\"RPC connection accepted\" remote=\"127.0.0.1:35148\""
time="2026-06-29T16:13:47+05:30" level=debug msg="() DBG | time=\"2026-06-29T16:13:47+05:30\" level=debug msg=\"RPC server invocation\" machine=default operation=GetVersion"
time="2026-06-29T16:13:47+05:30" level=debug msg="() DBG | time=\"2026-06-29T16:13:47+05:30\" level=warning msg=\"RPC server invocation\" config_bytes=769 machine=default operation=SetConfigRaw"
time="2026-06-29T16:13:47+05:30" level=debug msg="() DBG | time=\"2026-06-29T16:13:47+05:30\" level=debug msg=\"RPC server invocation\" machine=crc operation=GetMachineName"
time="2026-06-29T16:13:47+05:30" level=debug msg="(crc) DBG | time=\"2026-06-29T16:13:47+05:30\" level=debug msg=\"RPC server invocation\" machine=crc operation=GetBundleName"
time="2026-06-29T16:13:47+05:30" level=debug msg="(crc) DBG | time=\"2026-06-29T16:13:47+05:30\" level=debug msg=\"RPC server invocation\" machine=crc operation=GetState"
time="2026-06-29T16:13:47+05:30" level=debug msg="(crc) DBG | time=\"2026-06-29T16:13:47+05:30\" level=info msg=\"RPC server invocation\" machine=crc operation=Close"

vyasgun added 2 commits June 24, 2026 13:19
Signed-off-by: Gunjan Vyas <vyasgun20@gmail.com>
Signed-off-by: Gunjan Vyas <vyasgun20@gmail.com>
@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Structured logging is added to the RPC driver plugin layer: a loggingListener/loggingConn wrapper logs TCP connection accept and close events, and a new logRPC helper instruments all RPCServerDriver methods with logrus entries. The deadcode linter is removed from .golangci.yml, and two UpdateConfigRaw parameter names are changed to _.

Changes

RPC Driver Logging and Cleanup

Layer / File(s) Summary
Unused parameter cleanup and linter removal
.golangci.yml, drivers/fakedriver/fakedriver.go, libmachine/drivers/base.go
deadcode linter entry removed; UpdateConfigRaw []byte parameter renamed to _ in both BaseDriver and fakedriver.
Connection-level logging wrappers
libmachine/drivers/plugin/register_driver.go
loggingListener and loggingConn types added to wrap the TCP listener; Accept() logs remote address on connect, Close() logs remote address and duration on disconnect; http.Serve updated to use the wrapper.
logRPC helper and per-method RPC logging
libmachine/drivers/rpc/server_driver.go
logrus imported; logRPC helper added with recover()-guarded machine-name retrieval; all RPCServerDriver methods (Close, GetVersion, GetConfigRaw, UpdateConfigRaw, SetConfigRaw, Create, DriverName, GetIP, GetMachineName, GetBundleName, GetState, Kill, PreCreateCheck, Remove, Start, Stop, GetSharedDirs) instrumented with structured log entries.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 A rabbit hops through every RPC call,
Leaving logrus breadcrumbs along the hall.
Connections are timed from accept to close,
Dead code linter gone — one less thing that slows.
With _ where unused params used to hide,
The warren is tidy, logs logged with pride! 🪵

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding logging for plugin RPC operations and connections.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

fmt.Println(listener.Addr())

go func() {
//nolint:gosec // localhost-only rpc server

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What was the gosec error?
You can replace

//nolint:gosec // localhost-only rpc server

with

//#nosec G703 localhost-only RPC server

with G703 replaced with the actual gosec error would provide more details

Comment thread .golangci.yml
- gofmt
- gosec
- gocritic
- deadcode

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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…

}

func (r *RPCServerDriver) DriverName(_ *struct{}, reply *string) error {
r.logRPC("DriverName", log.DebugLevel, nil)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

How did you decide between the various log levels?

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.

2 participants