From 7887b2b448e63263a52880d7024a22038386b41b Mon Sep 17 00:00:00 2001 From: "blink-so[bot]" <211532188+blink-so[bot]@users.noreply.github.com> Date: Fri, 5 Dec 2025 22:32:28 +0000 Subject: [PATCH 1/2] feat(agent): add configurable metadata report interval Add CODER_AGENT_REPORT_METADATA_INTERVAL env var to control how often the agent reports metadata to the Coder server. This helps reduce database load from pg_notify spam in deployments with many agents. The default remains 1s for backwards compatibility, but operators can now increase this interval if they experience database pressure from metadata updates. --- cli/agent.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/cli/agent.go b/cli/agent.go index 56a8720a4116f..f46dbc52a0cb1 100644 --- a/cli/agent.go +++ b/cli/agent.go @@ -59,6 +59,7 @@ func workspaceAgent() *serpent.Command { devcontainerDiscoveryAutostart bool socketServerEnabled bool socketPath string + reportMetadataInterval time.Duration ) agentAuth := &AgentAuth{} cmd := &serpent.Command{ @@ -319,8 +320,9 @@ func workspaceAgent() *serpent.Command { agentcontainers.WithProjectDiscovery(devcontainerProjectDiscovery), agentcontainers.WithDiscoveryAutostart(devcontainerDiscoveryAutostart), }, - SocketPath: socketPath, - SocketServerEnabled: socketServerEnabled, + SocketPath: socketPath, + SocketServerEnabled: socketServerEnabled, + ReportMetadataInterval: reportMetadataInterval, }) if debugAddress != "" { @@ -494,6 +496,13 @@ func workspaceAgent() *serpent.Command { Description: "Specify the path for the agent socket.", Value: serpent.StringOf(&socketPath), }, + { + Flag: "report-metadata-interval", + Default: "1s", + Env: "CODER_AGENT_REPORT_METADATA_INTERVAL", + Description: "The interval at which the agent reports metadata to the Coder server. Lower values result in more frequent updates but higher database load.", + Value: serpent.DurationOf(&reportMetadataInterval), + }, } agentAuth.AttachOptions(cmd, false) return cmd From b96f251a0712ae2ea9e95664350d5a450dd7ee14 Mon Sep 17 00:00:00 2001 From: "blink-so[bot]" <211532188+blink-so[bot]@users.noreply.github.com> Date: Fri, 5 Dec 2025 22:39:40 +0000 Subject: [PATCH 2/2] chore: update golden file for agent --help --- cli/testdata/coder_agent_--help.golden | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cli/testdata/coder_agent_--help.golden b/cli/testdata/coder_agent_--help.golden index d262c0d0c7618..5a0e05c276d2b 100644 --- a/cli/testdata/coder_agent_--help.golden +++ b/cli/testdata/coder_agent_--help.golden @@ -64,6 +64,10 @@ OPTIONS: --prometheus-address string, $CODER_AGENT_PROMETHEUS_ADDRESS (default: 127.0.0.1:2112) The bind address to serve Prometheus metrics. + --report-metadata-interval duration, $CODER_AGENT_REPORT_METADATA_INTERVAL (default: 1s) + The interval at which the agent reports metadata to the Coder server. + Lower values result in more frequent updates but higher database load. + --script-data-dir string, $CODER_AGENT_SCRIPT_DATA_DIR (default: /tmp) Specify the location for storing script data.