## What Runs the workspace agent logger at `Info` with a slog flight recorder (`v3.2.0`) instead of unconditionally at `Debug`. Entries below the current log level are kept in a rolling in-memory ring and flushed to the sinks when the agent loses its connection to coderd (and before any `Error`+ log), so the detail leading up to a failure is available without writing debug logs during normal operation. Implements CLIENT-672 (connection-log RFC req 13) for the workspace agent. Depends on the `cdr.dev/slog/v3` `v3.2.0` bump (already on `main`). ## How - `cli/agent.go`: - The main agent logger is `AppendSinks(...).Leveled(level).FlightRecorder(flightRecorderSize)`, where `level` is `Info` by default and `Debug` under the global `-v` / `CODER_VERBOSE`. The recorder is always attached; at `Debug` it is inert, which keeps the setup correct if the configured level changes in the future. The reaper logger is unchanged. - New `--agent-flight-recorder-size` / `CODER_AGENT_FLIGHT_RECORDER_SIZE` (default `1000`, `0` disables the flight recorder), so the ring size is configurable per RFC req 13. The agent flag is distinct from CLI-4's global `--flight-recorder-size` (#29752) so the two don't collide when `coder agent` inherits the root global. - `workspaceAgent` is a `RootCmd` method so it reuses the root command's global verbose flag instead of defining an agent-specific one. - `agent/agent.go` (`runLoop`): on a lost coderd connection (the `io.EOF` disconnect and the generic run error) the agent calls `logger.Flush(ctx)` to emit the recorded history and then logs at `Warn`. These are `Warn` rather than `Error` because reconnectable disconnects are expected and `slogtest` fails tests on any `Error` log; the manual flush is what surfaces the recorded detail. Graceful shutdown paths (`ctx` canceled, agent closed) are not flushed. - Tests: `agent.TestAgent_FlushFlightRecorderOnDisconnect` covers the flush-on-disconnect path; `cli.TestWorkspaceAgent/DisabledServers` runs with verbose since its debug messages are otherwise recorded. Golden `--help` output regenerated. ## Default log verbosity change This changes the default agent-log verbosity. Today `coder-agent.log` receives `Debug` unconditionally; with this change, normal operation logs `Info`, and recorded below-level entries are emitted only when the agent loses its coderd connection (via a manual flush) or before any `Error`+ log, or always under `-v` / `CODER_VERBOSE`. This is the intended behavior of the feature: a quiet steady state with full detail retained for diagnosing failures. Operators who want the previous always-debug output can run with `-v` / `CODER_VERBOSE`. ## Alignment with #29752 (CLI) This mirrors the CLI-4 (CLI log buffer) design so the two implementations agree: - **Level model:** Info by default, debug available on demand via the global `-v` / `CODER_VERBOSE`. - **Flight recorder size:** default `1000`, `0` disables. CLI-4 exposes a global `--flight-recorder-size`; the agent uses a distinct `--agent-flight-recorder-size` / `CODER_AGENT_FLIGHT_RECORDER_SIZE` (the `CODER_AGENT_*` env convention) so the inherited global and the agent flag coexist without collision. - **Flush trigger:** the recorded history is emitted before any `Error`+ log via slog's auto-flush. The agent additionally flushes manually on a lost coderd connection, which it logs at `Warn` (reconnectable, and `Error` would fail `slogtest`-based tests); the CLI's failures are fatal, so it relies on the auto-flush-on-error. <details> <summary>Rollout context</summary> Cross-repo sequence: coder/slog flight recorder (released as v3.2.0) -> go.mod bump in coder/coder (#29600, merged) -> this PR (CLIENT-672, agent) and CLI-4 (CLI), which are independent consumers and can merge in any order. </details> --- <sub>Opened by Coder Agents on behalf of @aqandrew.</sub>
103 lines
4.3 KiB
Plaintext
103 lines
4.3 KiB
Plaintext
coder v0.0.0-devel
|
|
|
|
USAGE:
|
|
coder agent [flags]
|
|
|
|
Starts the Coder workspace agent.
|
|
|
|
OPTIONS:
|
|
--auth string, $CODER_AGENT_AUTH (default: token)
|
|
Specify the authentication type to use for the agent.
|
|
|
|
--agent-name string, $CODER_AGENT_NAME
|
|
The name of the agent to authenticate as (only applicable for instance
|
|
identity).
|
|
|
|
--agent-token string, $CODER_AGENT_TOKEN
|
|
An agent authentication token.
|
|
|
|
--agent-token-file string, $CODER_AGENT_TOKEN_FILE
|
|
A file containing an agent authentication token.
|
|
|
|
--agent-url url, $CODER_AGENT_URL
|
|
URL for an agent to access your deployment.
|
|
|
|
--log-human string, $CODER_AGENT_LOGGING_HUMAN (default: /dev/stderr)
|
|
Output human-readable logs to a given file.
|
|
|
|
--log-json string, $CODER_AGENT_LOGGING_JSON
|
|
Output JSON logs to a given file.
|
|
|
|
--log-stackdriver string, $CODER_AGENT_LOGGING_STACKDRIVER
|
|
Output Stackdriver compatible logs to a given file.
|
|
|
|
--agent-firewall-log-proxy-socket-path string, $CODER_AGENT_FIREWALL_LOG_PROXY_SOCKET_PATH (default: /tmp/boundary-audit.sock)
|
|
The path for the agent firewall log proxy server Unix socket. Agent
|
|
firewall should write audit logs to this socket.
|
|
|
|
--agent-flight-recorder-size int, $CODER_AGENT_FLIGHT_RECORDER_SIZE (default: 1000)
|
|
Number of log entries below the current log level to keep in memory
|
|
and emit on errors. Set to 0 to disable the flight recorder.
|
|
|
|
--agent-header string-array, $CODER_AGENT_HEADER
|
|
Additional HTTP headers added to all requests. Provide as key=value.
|
|
Can be specified multiple times.
|
|
|
|
--agent-header-command string, $CODER_AGENT_HEADER_COMMAND
|
|
An external command that outputs additional HTTP headers added to all
|
|
requests. The command must output each header as `key=value` on its
|
|
own line.
|
|
|
|
--block-file-transfer bool, $CODER_AGENT_BLOCK_FILE_TRANSFER (default: false)
|
|
Block file transfer using known applications: nc,rsync,scp,sftp.
|
|
|
|
--block-local-port-forwarding bool, $CODER_AGENT_BLOCK_LOCAL_PORT_FORWARDING (default: false)
|
|
Block local port forwarding through the SSH server (ssh -L).
|
|
|
|
--block-reverse-port-forwarding bool, $CODER_AGENT_BLOCK_REVERSE_PORT_FORWARDING (default: false)
|
|
Block reverse port forwarding through the SSH server (ssh -R).
|
|
|
|
--debug-address string, $CODER_AGENT_DEBUG_ADDRESS (default: 127.0.0.1:2113)
|
|
The bind address to serve a debug HTTP server.
|
|
|
|
--devcontainers-discovery-autostart-enable bool, $CODER_AGENT_DEVCONTAINERS_DISCOVERY_AUTOSTART_ENABLE (default: false)
|
|
Allow the agent to autostart devcontainer projects it discovers based
|
|
on their configuration.
|
|
|
|
--devcontainers-enable bool, $CODER_AGENT_DEVCONTAINERS_ENABLE (default: true)
|
|
Allow the agent to automatically detect running devcontainers.
|
|
|
|
--devcontainers-project-discovery-enable bool, $CODER_AGENT_DEVCONTAINERS_PROJECT_DISCOVERY_ENABLE (default: true)
|
|
Allow the agent to search the filesystem for devcontainer projects.
|
|
|
|
--log-dir string, $CODER_AGENT_LOG_DIR (default: /tmp)
|
|
Specify the location for the agent log files.
|
|
|
|
--no-reap bool
|
|
Do not start a process reaper.
|
|
|
|
--pprof-address string, $CODER_AGENT_PPROF_ADDRESS (default: 127.0.0.1:6060)
|
|
The address to serve pprof.
|
|
|
|
--prometheus-address string, $CODER_AGENT_PROMETHEUS_ADDRESS (default: 127.0.0.1:2112)
|
|
The bind address to serve Prometheus metrics.
|
|
|
|
--script-data-dir string, $CODER_AGENT_SCRIPT_DATA_DIR (default: /tmp)
|
|
Specify the location for storing script data.
|
|
|
|
--socket-path string, $CODER_AGENT_SOCKET_PATH
|
|
Specify the path for the agent socket.
|
|
|
|
--socket-server-enabled bool, $CODER_AGENT_SOCKET_SERVER_ENABLED (default: true)
|
|
Enable the agent socket server.
|
|
|
|
--ssh-max-timeout duration, $CODER_AGENT_SSH_MAX_TIMEOUT (default: 72h)
|
|
Specify the max timeout for a SSH connection, it is advisable to set
|
|
it to a minimum of 60s, but no more than 72h.
|
|
|
|
--tailnet-listen-port int, $CODER_AGENT_TAILNET_LISTEN_PORT (default: 0)
|
|
Specify a static port for Tailscale to use for listening.
|
|
|
|
———
|
|
Run `coder --help` for a list of global options.
|