Support runtime log level adjustment on spire-agent#7057
Conversation
5071a1d to
e1e2a59
Compare
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a new Agent Admin API “Logger” service and supporting CLI tooling to view/change/reset the agent log level at runtime, including connection telemetry for that service.
Changes:
- Introduces
spire.api.agent.logger.v1.LoggergRPC service (GetLogger/SetLogLevel/ResetLogLevel) and registers it on the agent Admin API server. - Adds connection metrics emission for Logger API traffic (counter + active connections gauge).
- Adds
spire-agent logger {get,set,reset}CLI commands plus shared OS-specific dial/flag utilities.
Reviewed changes
Copilot reviewed 30 out of 30 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/common/telemetry/names.go | Adds LoggerAPI telemetry namespace constant. |
| pkg/common/telemetry/agent/adminapi/loggerapi.go | Adds helper functions to emit Logger API connection metrics. |
| pkg/common/api/middleware/names.go | Adds agent logger service full name and includes it in tracked service names. |
| pkg/agent/endpoints/metrics.go | Emits connection metrics for the agent logger service. |
| pkg/agent/endpoints/metrics_test.go | Adds coverage ensuring logger service is handled by connection-metrics middleware. |
| pkg/agent/api/logger/v1/service.go | Implements the agent logger Admin API service. |
| pkg/agent/api/logger/v1/levels.go | Adds log level translation maps (logrus ↔ API). |
| pkg/agent/api/logger/v1/service_test.go | Adds unit tests for logger service behaviors and logging. |
| pkg/agent/api/endpoints.go | Registers the logger API on the agent admin endpoints. |
| pkg/agent/api/config.go | Adds RootLog to admin API config for runtime log level control. |
| pkg/agent/agent.go | Wires RootLog into admin endpoints; changes constructor to return an error. |
| cmd/spire-agent/util/util.go | Adds shared CLI adapter + gRPC client helper for agent Admin API. |
| cmd/spire-agent/util/util_posix.go | Adds socket-path flag and unix dialer. |
| cmd/spire-agent/util/util_windows.go | Adds named-pipe flag and Windows named-pipe dialer. |
| cmd/spire-agent/cli/logger/*.go | Implements logger get/set/reset commands + pretty printer. |
| cmd/spire-agent/cli/logger/*_test.go | Adds CLI tests and OS-specific usage expectations. |
| cmd/spire-agent/cli/cli.go | Registers new CLI subcommands. |
Comments suppressed due to low confidence (1)
pkg/common/api/middleware/names.go:1
- The agent logger service is mapped using
LoggerServiceShortName, implicitly reusing the same short name as the server logger service. If this pairing is intentional, it would be clearer to introduce an explicitAgentLoggerServiceShortNameconstant (even if it equals"Logger") or add a brief comment explaining the intentional reuse, to avoid confusion and reduce the chance of future mis-pairing when this list is edited.
package middleware
Implements the Logger API (GetLogger, SetLogLevel, ResetLogLevel) on the agent admin socket, bringing the agent to parity with the server. Adds CLI commands (spire-agent logger get/set/reset) and connection metrics. Closes spiffe#4986 Signed-off-by: Raushan Singh <rausingh@redhat.com>
e1e2a59 to
f4f67da
Compare
|
There's another PR open for this: #7017 |
|
Hi @sorindumitru thanks for the heads-up! I wasn't aware of #7017 when I opened this. Since your PR covers the same feature, I'll close this in favor of it. Happy to help review or test #7017 if needed. |
Yes, if you can help with reviewing, that would be appreciated. Thanks! |
Closes #4986
Implements the Logger API (GetLogger, SetLogLevel, ResetLogLevel) on the agent's admin UDS, bringing the agent to parity with the server. The API already existed in spire-api-sdk (
proto/spire/api/agent/logger/v1), this PR adds the service implementation, CLI commands, telemetry, and tests.