chore: rename agent firewall flags (#27231)

* Alias --boundary-log-proxy-socket-path to
--agent-firewall-log-proxy-socket-path
* Also alias CODER_AGENT_BOUNDARY_LOG_PROXY_SOCKET_PATH to
CODER_AGENT_FIREWALL_LOG_PROXY_SOCKET_PATH
* Also Rename related variables and symbols to reflect the new name.

<!--

If you have used AI to produce some or all of this PR, please ensure you
have read our [AI Contribution
guidelines](https://coder.com/docs/about/contributing/AI_CONTRIBUTING)
before submitting.

-->
This commit is contained in:
Sas Swart
2026-07-20 15:39:21 +02:00
committed by GitHub
parent a9fdf87a2f
commit 66e6f40b8b
3 changed files with 92 additions and 79 deletions
+47 -48
View File
@@ -100,25 +100,25 @@ type Options struct {
IgnorePorts map[int]string
// ListeningPortsGetter is used to get the list of listening ports. Only
// tests should set this. If unset, a default that queries the OS will be used.
ListeningPortsGetter ListeningPortsGetter
SSHMaxTimeout time.Duration
TailnetListenPort uint16
Subsystems []codersdk.AgentSubsystem
PrometheusRegistry *prometheus.Registry
ReportMetadataInterval time.Duration
ServiceBannerRefreshInterval time.Duration
BlockFileTransfer bool
BlockReversePortForwarding bool
BlockLocalPortForwarding bool
Execer agentexec.Execer
Devcontainers bool
DevcontainerAPIOptions []agentcontainers.Option // Enable Devcontainers for these to be effective.
GitAPIOptions []agentgit.Option
Clock quartz.Clock
SocketServerEnabled bool
SocketPath string // Path for the agent socket server socket
BoundaryLogProxySocketPath string
ContextConfig agentcontextconfig.Config
ListeningPortsGetter ListeningPortsGetter
SSHMaxTimeout time.Duration
TailnetListenPort uint16
Subsystems []codersdk.AgentSubsystem
PrometheusRegistry *prometheus.Registry
ReportMetadataInterval time.Duration
ServiceBannerRefreshInterval time.Duration
BlockFileTransfer bool
BlockReversePortForwarding bool
BlockLocalPortForwarding bool
Execer agentexec.Execer
Devcontainers bool
DevcontainerAPIOptions []agentcontainers.Option // Enable Devcontainers for these to be effective.
GitAPIOptions []agentgit.Option
Clock quartz.Clock
SocketServerEnabled bool
SocketPath string // Path for the agent socket server socket
AgentFirewallLogProxySocketPath string
ContextConfig agentcontextconfig.Config
// DERPTLSConfig is an optional TLS config for DERP connections.
DERPTLSConfig *tls.Config
// StatsReportInterval is the interval for the connstats callback
@@ -253,14 +253,14 @@ func New(options Options) Agent {
metrics: newAgentMetrics(prometheusRegistry),
execer: options.Execer,
devcontainers: options.Devcontainers,
containerAPIOptions: options.DevcontainerAPIOptions,
gitAPIOptions: options.GitAPIOptions,
socketPath: options.SocketPath,
socketServerEnabled: options.SocketServerEnabled,
boundaryLogProxySocketPath: options.BoundaryLogProxySocketPath,
contextConfig: options.ContextConfig,
derpTLSConfig: options.DERPTLSConfig,
devcontainers: options.Devcontainers,
containerAPIOptions: options.DevcontainerAPIOptions,
gitAPIOptions: options.GitAPIOptions,
socketPath: options.SocketPath,
socketServerEnabled: options.SocketServerEnabled,
agentFirewallLogProxySocketPath: options.AgentFirewallLogProxySocketPath,
contextConfig: options.ContextConfig,
derpTLSConfig: options.DERPTLSConfig,
}
// Initially, we have a closed channel, reflecting the fact that we are not initially connected.
// Each time we connect we replace the channel (while holding the closeMutex) with a new one
@@ -337,11 +337,11 @@ type agent struct {
logSender *agentsdk.LogSender
// boundaryLogProxy is a socket server that forwards boundary audit logs to coderd.
// agentFirewallLogProxy is a socket server that forwards Agent Firewall audit logs to coderd.
// It may be nil if there is a problem starting the server.
boundaryLogProxy *boundarylogproxy.Server
boundaryLogProxySocketPath string
contextConfig agentcontextconfig.Config
agentFirewallLogProxy *boundarylogproxy.Server
agentFirewallLogProxySocketPath string
contextConfig agentcontextconfig.Config
prometheusRegistry *prometheus.Registry
// metrics are prometheus registered metrics that will be collected and
@@ -540,7 +540,7 @@ func (a *agent) init() {
)
a.initSocketServer()
a.startBoundaryLogProxyServer()
a.startAgentFirewallLogProxyServer()
// Start the agentcontext manager's resolver/watcher loop.
// It runs for the lifetime of the agent and is closed in
@@ -576,22 +576,21 @@ func (a *agent) initSocketServer() {
a.logger.Debug(a.hardCtx, "socket server started", slog.F("path", a.socketPath))
}
// startBoundaryLogProxyServer starts the boundary log proxy socket server.
func (a *agent) startBoundaryLogProxyServer() {
if a.boundaryLogProxySocketPath == "" {
a.logger.Warn(a.hardCtx, "boundary log proxy socket path not defined; not starting proxy")
func (a *agent) startAgentFirewallLogProxyServer() {
if a.agentFirewallLogProxySocketPath == "" {
a.logger.Warn(a.hardCtx, "agent firewall log proxy socket path not defined; not starting proxy")
return
}
proxy := boundarylogproxy.NewServer(a.logger, a.boundaryLogProxySocketPath, a.prometheusRegistry)
proxy := boundarylogproxy.NewServer(a.logger, a.agentFirewallLogProxySocketPath, a.prometheusRegistry)
if err := proxy.Start(); err != nil {
a.logger.Warn(a.hardCtx, "failed to start boundary log proxy", slog.Error(err))
a.logger.Warn(a.hardCtx, "failed to start agent firewall log proxy", slog.Error(err))
return
}
a.boundaryLogProxy = proxy
a.logger.Info(a.hardCtx, "boundary log proxy server started",
slog.F("socket_path", a.boundaryLogProxySocketPath))
a.agentFirewallLogProxy = proxy
a.logger.Info(a.hardCtx, "agent firewall log proxy server started",
slog.F("socket_path", a.agentFirewallLogProxySocketPath))
}
// runLoop attempts to start the agent in a retry loop.
@@ -1229,13 +1228,13 @@ func (a *agent) run() (retErr error) {
return err
})
// Forward boundary audit logs to coderd if boundary log forwarding is enabled.
// Forward Agent Firewall audit logs to coderd if agent firewall log forwarding is enabled.
// These are audit logs so they should continue during graceful shutdown.
if a.boundaryLogProxy != nil {
if a.agentFirewallLogProxy != nil {
proxyFunc := func(ctx context.Context, aAPI proto.DRPCAgentClient28) error {
return a.boundaryLogProxy.RunForwarder(ctx, aAPI)
return a.agentFirewallLogProxy.RunForwarder(ctx, aAPI)
}
connMan.startAgentAPI("boundary log proxy", gracefulShutdownBehaviorRemain, proxyFunc)
connMan.startAgentAPI("agent firewall log proxy", gracefulShutdownBehaviorRemain, proxyFunc)
}
// part of graceful shut down is reporting the final lifecycle states, e.g "ShuttingDown" so the
@@ -2414,10 +2413,10 @@ func (a *agent) Close() error {
a.logger.Error(a.hardCtx, "agentcontext manager close", slog.Error(err))
}
if a.boundaryLogProxy != nil {
err = a.boundaryLogProxy.Close()
if a.agentFirewallLogProxy != nil {
err = a.agentFirewallLogProxy.Close()
if err != nil {
a.logger.Warn(context.Background(), "close boundary log proxy", slog.Error(err))
a.logger.Warn(context.Background(), "close agent firewall log proxy", slog.Error(err))
}
}